Script out Procedures and Functions - Part 2

Published 13 December 07 11:57 AM | Madhivanan 

 

Part 1 uses information_Schema.routines view and this is based on sp_helptext

 

declare @sps table(texts varchar(8000))

insert into @sps

select 'sp_helptext '''+name+'''' from sysobjects where xtype in ('p','fn')

order by xtype,name

 

create table scripts(sps varchar(8000))

 

declare @texts varchar(1000)

select @texts=min(texts)from @sps

while @texts>''

Begin

EXEC('insert into scripts(sps) EXEC '+ @texts)

insert into scripts(sps) select 'GO'

select @texts=min(texts)from @sps where texts>@texts

End

EXEC master..xp_cmdshell 'bcp "select * from dbname..scripts" queryout "c:\scripts.txt" -c' 

drop table scripts

Filed under: ,

Comments

# Other SQL Server Blogs around the Web said on December 13, 2007 7:22 AM:

Part 1 uses information_Schema.routines view and this is based on sp_helptext declare @sps table ( texts

# SSQA.net - SqlServer-QA.net said on December 13, 2007 8:34 AM:

Part 1 uses information_Schema.routines view and this is based on sp_helptext declare @sps table ( texts

Anonymous comments are disabled

Search

Go

This Blog

«December 2007»
SMTWTFS
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

Syndication