Import Stored Procedure Scripts

  • We exported all of our SP's to .sql files to modify them. I need to import the 600+ .sql files back into SQL. What is the best way to accomplish this task?

  • Three methods come to mind:

    1. Redgate SQL Compare allows you to compare the database against scripts and sync the changes

    2. Source Control. Deploy your sql files through an automated build system

    3. Execute the script files in SSMS.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Here is what I finally did to accomplish task:

    navigated to the folder containing all the Stored Procedures

    Ran the following command c:>\dir /b >c:\SP_File.txt

    ********* SP_File.txt ************

    vm_my_StoredProd1.sql

    vm_my_StoredProd2.sql

    vm_my_StoredProd3.sql

    vm_my_StoredProd4.sql

    ~ truncated

    **************************

    Opened the SP_File.txt in MS Excel and appended the following SQLCMD syntax

    ****** SP_File.bat ********

    SQLCMD -i C:\SP\vm_my_StoredProd1.sql

    SQLCMD -i C:\SP\vm_my_StoredProd2.sql

    SQLCMD -i C:\SP\vm_my_StoredProd3.sql

    SQLCMD -i C:\SP\vm_my_StoredProd4.sql

    ~ truncated

    Now I saved the file as a .bat file instead of a text file and ran it!

    I also used Notepad++ (Freeware) to open all the .sql files sequentially and changed the "Create" stored procedure to "Alter"

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

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