Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to insert database table fields values into another database in Sql server 2005
Posted
Updated 10-Feb-13 22:17pm
v2
Comments
Irbaz Haider Hashmi 11-Feb-13 4:08am    
Are you referring to Link Server?
insert into Table1
Select * from [LINKESERVERNAME].[DATABASENAME].[dbo].[TABLENAME]
Bala Selvanayagam 11-Feb-13 4:20am    
Is the second database is is in the same SQL server instance or in a different computer ?

1 solution

If the databases are on the same server you can do (given the table structures match exactly) :
SQL
insert into [dbo.db1.totable] 
select * from [dbo.db2.fromtable]

If not then create a "linked server" then do the above : http://msdn.microsoft.com/en-us/library/aa213778%28v=sql.80%29.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900