Results 1 to 4 of 4

Thread: Create database and create table

  1. #1
    Join Date
    May 2003
    Posts
    30

    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

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Try add 'use db_name go' before 'create table' statement to switch to correct db.

  3. #3
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You have to qualify each object with databasename.ownername

  4. #4
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    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
  •