I currently have two DB's (DB1 and DB2) setup on an instance of SQL server. DB2 is essentially a reporting store which I populate with data from DB1
Currently: my Extract script takes the following parameters:
@sourceDatabase sysname, @YearMonthStart int, @YearMonthEnd int
Within the script I list a number of tables to be populated based on these parameters.
INSERT INTO TableX
EXEC ('USE '+ @sourceDatabase + ' EXEC spPopulateTableX')
I am now migrating DB2 to new server and the two servers are setup as linked servers.
So I cannot use 'USE' anmore.
So essentially my questions is how do a reference the source database in my script?
All help is appreciated.