Monday, March 19, 2012

Creating SQL Script with code

Hello there
I have huge databse that i need to generate it to script sometimes
The Sql Generate SQL Script tool is not smart: it build the tables, views,
store procedures and function on the end. But if the view or store procedure
is based on one of the functions the script won't work
Therefore i need to develop my own tool for scripting databse.
Is the a way to get script that create each object in the system, including
all its items?
..
roy@.atidsm.co.il
: 03-5611606
' 050-7709399> The Sql Generate SQL Script tool is not smart: it build the tables, views,
> store procedures and function on the end. But if the view or store
procedure
> is based on one of the functions the script won't work
If you are using EM, you can find on the Formatting tab an otion to include
all dependet objects.

> Therefore i need to develop my own tool for scripting databse.
> Is the a way to get script that create each object in the system,
including
> all its items?
As EM and QA, you can use SQL DMO to script objects. heck
http://www.karaszi.com/sqlserver/in...ate_script.asp.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com|||Hi,
I would suggest you to use sp_helptext or retrieve info from syscomments
table.
Ed
"Roy Goldhammer" wrote:

> Hello there
> I have huge databse that i need to generate it to script sometimes
> The Sql Generate SQL Script tool is not smart: it build the tables, views,
> store procedures and function on the end. But if the view or store procedu
re
> is based on one of the functions the script won't work
> Therefore i need to develop my own tool for scripting databse.
> Is the a way to get script that create each object in the system, includin
g
> all its items?
> --
> ??òé a?ì????
> ù.?. òúé? ?e??ú ú??e?
> roy@.atidsm.co.il
> èì: 03-5611606
> ?ì_' 050-7709399
>
>|||Perhaps you messe dsomething up, there is a way to script all object
depending the one you want to have via UI. SO the follwing code, will
procuding the script for creating the Function and the view if you only
select the view to create and check the checkbox saying to script also
depending objects.
Try it out,
HTH, Jens Smeyer.
http://www.sqlserver2005.de
--
CREATE FUNCTION [dbo].FCT_YadaYada()
RETURNS INT AS
BEGIN
return 1
END
Create View VI_YadaYada
AS
Select dbo.FCT_YadaYada() as YadaYada
"Roy Goldhammer" <roygoldh@.hotmail.com> schrieb im Newsbeitrag
news:%23%23pvEFYQFHA.3076@.tk2msftngp13.phx.gbl...
> Hello there
> I have huge databse that i need to generate it to script sometimes
> The Sql Generate SQL Script tool is not smart: it build the tables, views,
> store procedures and function on the end. But if the view or store
> procedure
> is based on one of the functions the script won't work
> Therefore i need to develop my own tool for scripting databse.
> Is the a way to get script that create each object in the system,
> including
> all its items?
> --
>
> ..
> roy@.atidsm.co.il
> : 03-5611606
> ' 050-7709399
>

No comments:

Post a Comment