Re: Scripting T-SQL CREATE Statements
From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 05/13/04
- Next message: Brandon: "RE: ODBC & SQLExecDirect"
- Previous message: Eric Lemmon: "Scripting T-SQL CREATE Statements"
- In reply to: Eric Lemmon: "Scripting T-SQL CREATE Statements"
- Next in thread: David Portas: "Re: Scripting T-SQL CREATE Statements"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 13 May 2004 16:26:03 +0200
Eric,
sp_helptext gives you the source code for most objects. Not indexes or tables, though. For these, you can use
SQLDMO, for instance. You might want to check my article at below URL which describes some options:
http://www.karaszi.com/SQLServer/info_generate_script.asp
-- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp "Eric Lemmon" <E_MAIL_ME_AT_ericnlisa@hotmail.com> wrote in message news:eUijrVPOEHA.3312@tk2msftngp13.phx.gbl... Greetings, In a VB/C# .NET Windows application, I need to programmatically generate T-SQL script to create various tables, stored procedures, etc., in a given database into a single text/sql file. In essense, I want to make a backup of user-defined SQL Server objects. When the object in question happens to be a table, the user will have the option to backup the table's data as well. I am having a hard time finding the T-SQL functions and system stored procedures used to return the scripted CREATE statements, like when you right-click an object and select Script Object to New Window as >> Create. I am trying to get it much like the instnwnd.sql file that comes with the .NET Framework SDK v1.1. (It is located at C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Samples\Setup after installing the SDK.) This SQL file creates the schema and inserts all data for the Northwind sample database. It's pretty slick! It's fairly easy to script the tables since it can all be done within .NET code (even though it's much slower), but the other objects--namely, stored procedures and functions--are a bit tougher to crack. If possible, I would like to bypass .NET code and use as many SQL Server system stored procedures/functions as possible. If you know of some ideas or code examples, please reply. Many thanks, Eric
- Next message: Brandon: "RE: ODBC & SQLExecDirect"
- Previous message: Eric Lemmon: "Scripting T-SQL CREATE Statements"
- In reply to: Eric Lemmon: "Scripting T-SQL CREATE Statements"
- Next in thread: David Portas: "Re: Scripting T-SQL CREATE Statements"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|