Hi,
I have 2 databases in ms sql server that have the same tables and fields. how can i copy/add the data from select tables in one db to the same tables in the other?
insert into db2.dbo.table
select * from db1.dbo.table
“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
It will add, you can't overwrite a table in SQL (unless you drop it first,recreate it and populate it afterwards)
You can update a table (meaning changing data)
you can delete/truncate a table(meaning taking out data)
And you can insert data (meaning appending)
“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
Thanks!
My last question(s) is (well maybe my last!). I want to give a user the priviledges to do this copy, what access do I allow them? And can i install E Mngr on their workstation?
GRANT INSERT
ON db2.dbo.table
TO Mary, John, Tom
GO
GRANT SELECT
ON db1.dbo.table
TO Mary, John, Tom
GO
Lookup GRANT in Books On Line (BOL)
“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
What if the two databases are on twp different servers?
Do I have to export the data into a flat file first and then import it into the second database?
Is there any alternative way?
Which is the fastest?
you create libked servers and then
insert into server2.db2.dbo.table
select * from server1.db1.dbo.table
lookup linked servers in BOL
“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.