[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Running a large sql query

Posted on 2005-04-18
Medium Priority
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

Kevin3NF earned 2000 total points
ID: 13810172
You could put it into a stored procedure and call that procedure from the job step.
LVL 28

Expert Comment

ID: 13810173
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 70

Expert Comment

by:Scott Pletcher
ID: 13810178
You can use osql to run it.
LVL 70

Expert Comment

by:Scott Pletcher
ID: 13810185
Note that isql is a much older utility; for new uses, you should always use osql.

Author Comment

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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

834 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