Running Commands in Order in QA

  • I have three commands (CREATE DATABASE, USE DATABASE, CREATE TABLE) in a SQL script. When I type the first command and press run, the database it created successfully. I then append to this same file USE DATABASE and press run again. It continues to work. Then I append CREATE TABLE and run once more. The table is created successfully.

    Then I deleted the database, so I could test the entire script. I opened the .SQL script containing all three commands in the Query Analyzer and pressed run. The QA skipped to the last command and created the table resulting in the table being created in the master database.

    How do I get all three commands to run in the order they are in the script? Here is the SQL script that I have written:

    CREATE DATABASE [Chapel Attendance];
    USE [Chapel Attendance];
    CREATE TABLE attendancerecord(StudentID CHAR (6) NOT NULL,
    Date TIMESTAMP NOT NULL);

    What else do I need to do? I need to have this script prepared, so I can email it to my college where they will run the script on their server to create the database.

  • Try putting GO statements between each of the requests

    CREATE DATABASE [Chapel Attendance]

    GO

    USE [Chapel Attendance]

    GO

    CREATE TABLE attendancerecord(StudentID CHAR (6) NOT NULL

    Date TIMESTAMP NOT NULL)

    GO

    This might work for you



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Yeah that should be right.

    OR you could try praying (I'm guessing you'd be good at that).

     


    The systems fine with no users loggged in. Can we keep it that way ?br>

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply