-
Create database and create table
Hi
Hope someone can help.
I am writing a stored procedure that searchs for a database and if it doesn't exist in Master will create the database and within the same stored procedure will create the necessary tables.
Currently I am finding that because it is processing both from within the same transaction it will create the database and not the tables. Can someone please advise on whether this is possible and if so how.
Thanks
-
Try add 'use db_name go' before 'create table' statement to switch to correct db.
-
You have to qualify each object with databasename.ownername
-
I prefer to create .SQL scripts and execute it using OSQL or DTS package for these kind of one time DB schema creation instead of a procedure.
Procedures are used when you are often doing same set of operations again and again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|