Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    16

    Thumbs up Unanswered: Command to Apply Stored procedures in SQL server 2005

    Can anyone please provide me SQl command script and steps to apply multiple stored procedures to the database in SQL server 2005

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    CREATE PROC dbo.a
    AS
    BEGIN
      SELECT 'I am a proc' As a
    END
    GO
    
    CREATE PROC dbo.b
    AS
    BEGIN
      SELECT 'I am also a proc' As b
    END
    GO
    
    CREATE PROC dbo.c
    AS
    BEGIN
      SELECT 'Perhaps you should clarify your question' As answer
    END
    GO
    George
    Home | Blog

  3. #3
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Can do something like this too, if you have sprocs as separate .sql files somewhere.

    --************************************************** ****************************
    -- Please enable SQLCMD mode (In Microsoft SQL Server Management Studio, select
    -- "Query --> SQLCMD Mode" from the menu).
    --************************************************** ****************************

    --************************************************** ****************************
    -- MODIFY: (1) The database name (DATABASENAME)
    -- (2) The path to the SQL Scripts \Database directory (PATH)
    --************************************************** ****************************

    :setvar DATABASENAME "MyDB"
    :setvar PATH "C:\MSSQL\Application\MyDB\"


    print('Using DB')
    GO

    USE $(DATABASENAME);
    GO

    print('stored procs')
    GO

    --STORED PROCEDURES

    :r $(PATH)"StoredProcs\Sproc1.sql"
    :r $(PATH)"StoredProcs\Sproc2.sql"
    :r $(PATH)"StoredProcs\Sproc3.sql"
    :r $(PATH)"StoredProcs\Sproc4.sql"
    GO



  4. #4
    Join Date
    Oct 2009
    Posts
    16
    The latter one was expected and more useful,Anyhow thanks both of you for responding to the question.Wish you Happy New Year!!

Tags for this Thread

Posting Permissions

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