call one SQL script from another

Posted on 2012-08-15
Last Modified: 2012-08-20
I want to call one SQL script from another.  Can this be done?  

What I want is a main script that does nothing more then make calls to other scripts.
Question by:HLRosenberger
    LVL 11

    Expert Comment

    by:Simone B
    I would normally create "other" scripts as stored procedures. Then the main script can call the stored procedures.

    For example:

    Create procedure Mainproc
    as begin

    Declare @a int
    Declare @b int

    set @a = blahblah1
    set @b = blahblah2

    If @a = @b

    exec otherproc1

    exec otherproc2

    LVL 1

    Author Comment

    But I do not want to create procs.   These are just external scripts.
    LVL 1

    Accepted Solution

    I'm gonna use the sqlcmd in a batch file to call each script.
    LVL 1

    Author Closing Comment

    This is the way I choose to go...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now