Running a large sql query

Posted on 2005-04-18
Last Modified: 2010-03-19
I have a large *.sql file that I run regularly in Query analyzer.  I tried setting up a job in Management>>Sql Server Agent.  The max allowed in each step is 3200 characters.  My file is over 7800 characters.  Is there anyway to run this on a schedule without having to break this working query up?


Question by:joekus
    LVL 21

    Accepted Solution

    You could put it into a stored procedure and call that procedure from the job step.
    LVL 28

    Expert Comment

    You can execute the sql script using the following:

    EXECUTE master.dbo.xp_cmdshell 'isql -S <ServerName> -U <UserName> -P <Password> -d <DatabaseName> -i "YourFileNameHere"'
    LVL 68

    Expert Comment

    You can use osql to run it.
    LVL 68

    Expert Comment

    Note that isql is a much older utility; for new uses, you should always use osql.

    Author Comment

    Thanks for quick responses.  
    Liked the idea of stored procedure as one less place usrname and pwd is floating about.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now