Results 1 to 2 of 2

Thread: view script

  1. #1
    Join Date
    Jan 2004
    Posts
    35

    Unanswered: view script

    I know this may be simple but how do I create a script that creates multiple views. It doesn't like it if I put multiple create statements in one script.
    ie. Create view A as select * from table a ;
    Create view B as select * from table b

  2. #2
    Join Date
    Apr 2004
    Location
    Kansas City, MO
    Posts
    734

    Re: view script

    Originally posted by lula123
    I know this may be simple but how do I create a script that creates multiple views. It doesn't like it if I put multiple create statements in one script.
    ie. Create view A as select * from table a ;
    Create view B as select * from table b
    If you are going to run from Query Analyzer, you need a GO between each one. This makes each its own batch.

    If from a procedure or script, you need to wrap each in:

    BEGIN TRANSACTION
    CREATE
    COMMIT TRANSACTION

    BEGIN TRANSACTION
    CREATE
    COMMIT TRANSACTION

    etc, etc, etc
    MeanOldDBA
    derrickleggett@hotmail.com
    When life gives you a lemon, fire the DBA.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •