dbTalk Databases Forums  

Get the content of SP by using a tsql query

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Get the content of SP by using a tsql query in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
omtechguy
 
Posts: n/a

Default Get the content of SP by using a tsql query - 02-15-2011 , 03:46 AM






Does someone know how to do it?

Thanks.

Reply With Quote
  #2  
Old   
ES
 
Posts: n/a

Default Re: Get the content of SP by using a tsql query - 02-15-2011 , 04:19 AM






Il 15/02/2011 10.46, omtechguy ha scritto:
Quote:
Does someone know how to do it?

Thanks.
This is one of queries I've traced to get t-sql code

SELECT
NULL AS [Text],
ISNULL(smsp.definition, ssmsp.definition) AS [Definition]
FROM
sys.all_objects AS sp
LEFT OUTER JOIN sys.sql_modules AS smsp ON smsp.object_id = sp.object_id
LEFT OUTER JOIN sys.system_sql_modules AS ssmsp ON ssmsp.object_id =
sp.object_id
WHERE
(sp.type = N'P' OR sp.type = N'RF' OR
sp.type='PC')and(sp.name=N'nameofstoredprocedure' and
SCHEMA_NAME(sp.schema_id)=N'nameofschema')

Try replacing 'nameofstoredprocedure' and 'nameofschema' with your
object name and schema. This on SQL Server 2k5.

bye

Reply With Quote
  #3  
Old   
Gert-Jan Strik
 
Posts: n/a

Default Re: Get the content of SP by using a tsql query - 02-15-2011 , 12:13 PM



Try this:

sp_helptext my_stored_procedure

--
Gert-Jan


omtechguy wrote:
Quote:
Does someone know how to do it?

Thanks.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.