This statement works:
INSERT INTO TestDB2.dbo.MyTableName SELECT * FROM TestDB1.dbo2.MyTableName
This statement works not:
DECLARE @SourceDatabase varchar(50)
DECLARE @TargetDatabase varchar(50)
SET @SourceDatabase = 'TestDB1'
SET @TargetDatabase = 'TestDB2'
INSERT INTO @TargetDatabase.dbo.PrcConfiguration SELECT * FROM @SourceDatabase.sppm.CONFIGURATION
OR without the '@'
INSERT INTO TargetDatabase.dbo.PrcConfiguration SELECT * FROM SourceDatabase.dbo1.CONFIGURATION
dbo and dbo1 are the schema.
I want to move later data from multiple tables from one database to another database using the same tables.
What do I wrong?