Running a large sql query

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?


Who is Participating?
Kevin3NFConnect With a Mentor Commented:
You could put it into a stored procedure and call that procedure from the job step.
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"'
Scott PletcherSenior DBACommented:
You can use osql to run it.
Scott PletcherSenior DBACommented:
Note that isql is a much older utility; for new uses, you should always use osql.
joekusAuthor Commented:
Thanks for quick responses.  
Liked the idea of stored procedure as one less place usrname and pwd is floating about.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.