Click here to Skip to main content
15,891,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to insert multiple vales into the database while selecting data from another table. But the both tables are in separate database.

Thanks In advance.
Posted
Comments
Rajesh waran 11-Feb-15 4:35am    
Try like this,
insert into Database1.dbo.Table1(Column1,Column2) select Column1,Column2 from Database2.dbo.Table2

 
Share this answer
 
Comments
Kochathu Thomas Tinu 11-Feb-15 3:47am    
Thanks.
But i already mention that the both tables are in different database not in the single database.
Abhinav S 11-Feb-15 4:13am    
Check if setting up a link server suites your needs - https://msdn.microsoft.com/en-in/library/ms188279.aspx.
Kochathu Thomas Tinu 11-Feb-15 4:25am    
An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.

This error found when look into this page.
 
Share this answer
 
v2
Comments
Kochathu Thomas Tinu 11-Feb-15 3:47am    
Thanks.
But i already mention that the both tables are in different database not in the single database.

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