T-SQL to insert data from on SQL Server DB to another
Posted on 2009-05-12
I need some help in writing T-SQL to take data from on SQL Server 2005 DB and insert it into tables in another SQL Server 2005 DB. I've got one catch, the column names don't always match. For example:
"Data from" column name: Issued BOM ID
"Data to" column name: Issued_BOM_ID
The data types are the same but the "Data to" DB may have additional columns that are not in the "Data from" DB. I would expect these to be left a the default or null.
Also, the table names don't always match as follows:
"Data from" table name: Issued BOM
"Data to" table name: Issued_BOM
I think this part could be handled by having a list of "Data from" table names and "Data to" tables names and pass them to the procedure.
Anyone have any suggestions on how to write this T-SQL?