Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a DataBase Called TargetDataBase and another called DestinationDataBase
Target DataBase includes a table called A
Destination DataBase includes table called B which its schema has the schema of Table A and other columns
so table A can intersect with table B in specific count of columns
i want to insert Data From Table to Table B
i wish that there is a dynamic stored procedure that can do that
and if there is none i want the statement that can insert data from table in target database to table in destination database
Posted

1 solution

i guess you need something like this

Assume that you are connected to DestinationDataBase then

SQL
insert TableB
select * from TargetDataBase.dbo.TableA


and if not in DestinationDataBase then

SQL
insert DestinationDataBase.dbo.TableB
select * from TargetDataBase.dbo.TableA</pre>
 
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