Exporting T-SQL scripts from command line
I presume when you say scripts you are referring to stored procedures. If you don't want to script objects using...
Continue Reading This Article
Enjoy this article as well as all of our content, including E-Guides, news, tips and more.
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
You also agree that your personal information may be transferred and processed in the United States, and that you have read and agree to the Terms of Use and the Privacy Policy.

the GUI the best way is to do this using the SCRIPT method of SQL-DMO. The technical reference is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sqldmo/dmoref_m_s_0n1g.asp.
An example of this would be:
Dim server Dim sp SET server=CreateObject("SQLDMO.SQLServer") server.LoginSecure=True server.Connect "." For Each sp in server.Databases("Northwind").StoredProcedures If Not sp.SystemObject then sp.script 68,"c:\" & sp.name & "_script.sql" End If NextTo determine if the SP has been changed since last time you scripted it will be a little more difficult. You will need to check and retain the values of two columns from sysobjects table. The crdate column will tell you the last time the stored procedure was dropped and recreated. The schema_ver column will change every time the stored procedure is ALTER'd. You will need to track both for each stored procedure.
For More Information
- Dozens more answers to tough SQL Server questions from Tony Bain are available here.
- The Best Microsoft SQL Server Web Links: tips, tutorials, scripts, and more.
- The Best SQL Web Links
- Have a SQL Server tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical SQL Server questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on SQL-Transact SQL (T-SQL)
PRO+
Content
Find more PRO+ content and other member only offers, here.
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.
Meet all of our SQL Server experts
View all SQL Server questions and answers
0 comments
Oldest Newest