Home > Archive > MS SQL Server > October 2006 > script objects into separate files in SQL 05









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author script objects into separate files in SQL 05
Sergey Poberezovskiy

2006-10-24, 6:31 pm

Hi,

In SQL2000 there used to be an option to script selected database objects
into separate files - cannot find this option in 2005 version.

I used to use it to script all database objects and put them under VSS for
easier management.

Could anyone please tell where this option could be found, or what is the
preferred way to script database objects into files (I have a database with
about a hundred tables and a few hundred derived objects - views, functions,
procs, etc.) I do not see it practical to create one file per object type.

Any help is greatly appreciated.
Uri Dimant

2006-10-24, 6:31 pm

Hi
http://www.nigelrivett.net/DMO/AddToSourceSafe.html

Add Reference to Microosft.SQLServer.ConnectionInfo
Add Reference to Microosft.SQLServer.SMO

Imports System.IO
Imports Microsoft.SqlServer.Management.Smo
....
Dim SMOServer As Server = New Server("WARDYIT01")
SMOServer. SetDefaultInitFields
(GetType(StoredProce
dure), "IsSystemObject")

Dim soDrop As ScriptingOptions = New ScriptingOptions
soDrop.ScriptDrops = True
soDrop.IncludeIfNotExists = True

Dim sw As StreamWriter = New StreamWriter("c:\script.sql")

For Each sp As StoredProcedure In
SMOServer.Databases("northwind").StoredProcedures
If Not sp.IsSystemObject Then
For Each s As String In sp.Script(soDrop)
sw.WriteLine(s)
Next
End If
Next

Dim soCreate As ScriptingOptions = New ScriptingOptions
soCreate.Default = True

For Each sp As StoredProcedure In
SMOServer.Databases("northwind").StoredProcedures
If Not sp.IsSystemObject Then
For Each s As String In sp.Script(soCreate)
sw.WriteLine(s)
Next
End If
Next

sw.Close()

"Sergey Poberezovskiy" < SergeyPoberezovskiy@
discussions.microsoft.com> wrote
in message news:E68598F6-C496-4A84-A02F- B98CCDA2CC65@microso
ft.com...
> Hi,
>
> In SQL2000 there used to be an option to script selected database objects
> into separate files - cannot find this option in 2005 version.
>
> I used to use it to script all database objects and put them under VSS for
> easier management.
>
> Could anyone please tell where this option could be found, or what is the
> preferred way to script database objects into files (I have a database
> with
> about a hundred tables and a few hundred derived objects - views,
> functions,
> procs, etc.) I do not see it practical to create one file per object type.
>
> Any help is greatly appreciated.



Tibor Karaszi

2006-10-24, 6:31 pm

http://www.sqlteam.com/item.asp?ItemID=23185

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/



"Sergey Poberezovskiy" < SergeyPoberezovskiy@
discussions.microsoft.com> wrote in message
news:E68598F6-C496-4A84-A02F- B98CCDA2CC65@microso
ft.com...
> Hi,
>
> In SQL2000 there used to be an option to script selected database objects
> into separate files - cannot find this option in 2005 version.
>
> I used to use it to script all database objects and put them under VSS for
> easier management.
>
> Could anyone please tell where this option could be found, or what is the
> preferred way to script database objects into files (I have a database with
> about a hundred tables and a few hundred derived objects - views, functions,
> procs, etc.) I do not see it practical to create one file per object type.
>
> Any help is greatly appreciated.



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com