Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rafeequddin_ahmed
Starting Member
23 Posts |
Posted - 2007-09-19 : 02:17:01
|
Hi,I have two database.I want to import a table from database1 to database2 with table structure and data of that table.Thank in Adavance. |
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2007-09-19 : 03:06:47
|
[code]SELECT *INTO database2.dbo.tablename1FROM database1.dbo.tablename2WHERE ...[/code]this is assuming both databases are in the same server. If they are in separate servers you will need to create a linked server and then select from it. Also, the login you use will have to have privileges in both databases for this query to work.here is BOL entry for SELECT statement to use as reference http://msdn2.microsoft.com/en-us/library/ms143506.aspx-ec |
 |
|
rafeequddin_ahmed
Starting Member
23 Posts |
Posted - 2007-09-19 : 03:20:53
|
Thank for reply,Can u plz tell me how to link servers. |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-09-19 : 05:26:29
|
"how to link servers."To CREATE a linked Server see Books Online.To reference tables / databases between linked servers:SELECT *INTO server2.database2.dbo.tablename2FROM server1.database1.dbo.tablename1WHERE ... NOTE: You can omit the server name for whichever server you are connected to. However, if you are connected to, say, server3 then you can explicitly name server1 and server2Kristen |
 |
|
|
|
|