migrating data from one table to anoter in SQL server 2005
Posted on 2011-09-22
I have a set of tables in my source database.
The naming convention for the tables are:
I need to migrate data from XXXEmployee in source database to Employee table in my destination database.
Declare @Src_Table nvarchar(25)
, @Des_Table nvarchar(25)
Set @Src_Table = 'XXXSalary'
set @Des_Table = Substring('XXXSalary',3,6)
Insert into DES_DB_dbo.@des_Table
Select * From Src_DB.dbo.@src_Table
Q1. what is the correct way of writing above inset into syntax using parameters @des_Table and @src_Table?
Q2. How can I write a script in sql that goes through the tables in source database and one by one transfer them to destination database using query above?
Many thanks in advance