I am writing a series of sql queries which go thru the following steps.
1. create the data base using a date extension..
2. create a number of tables in the database created in step 1
3. populate the tables created in step 2
The problem I keep having is, even when I try to create the tables within a dynamic sql command...so that I can have a 'use' which uses the new database created...., the tables get created in the master database.. I think this might be because the query which creates the tables is held on the master db, and the sql job which runs all the steps runs step 2 using the master database... how do I force this query to use the new database created?????? I tried doing it through a batch job so that I create the database name as a command line variable, and then call the 'create table' query by doing -q ''master...creattablequery'' but it still creates the tables on master.... Does anyone know how I can achieve my main objective... which is to create the tables in the correct database (created in a variable).
1. create the data base using a date extension..
2. create a number of tables in the database created in step 1
3. populate the tables created in step 2
The problem I keep having is, even when I try to create the tables within a dynamic sql command...so that I can have a 'use' which uses the new database created...., the tables get created in the master database.. I think this might be because the query which creates the tables is held on the master db, and the sql job which runs all the steps runs step 2 using the master database... how do I force this query to use the new database created?????? I tried doing it through a batch job so that I create the database name as a command line variable, and then call the 'create table' query by doing -q ''master...creattablequery'' but it still creates the tables on master.... Does anyone know how I can achieve my main objective... which is to create the tables in the correct database (created in a variable).