Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 sql file
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

64 Posts

Posted - 01/27/2009 :  16:50:58  Show Profile  Reply with Quote
I have tons of .sql files. Can I create a single .sql file that will run all other sql file?

Posting Yak Master

220 Posts

Posted - 01/28/2009 :  13:54:34  Show Profile  Reply with Quote
Yes and there are multiple ways to do this.

You can combine all the files into one file and schedule them to run at a specific time using SQL Agent.

You can also combine them all together under a stored procedure and then simply execute that stored procedure.

or you can simple combine them all together in one sql file using sql management studio and hit F5 (which will execute all the queries).

Of course it may not be desirable to do any of those things depending on how it would load down your server. Generally speaking it is better to have several queries to break the work down rather than one giant query that would consume all your resources. If you are in charge of the database it is up to you to make that call.

There are numerous examples on the web on how to to these tasks. Google is your friend.

Go to Top of Page

Flowing Fount of Yak Knowledge

7174 Posts

Posted - 01/31/2009 :  15:42:37  Show Profile  Reply with Quote
You can use SQLCMD for it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000