How can I access the code behind a stored procedure
? Home
I am using Microsoft SQL Server Management Studio .
How can I access the code behind a stored procedure
? Home
I am using Microsoft SQL Server Management Studio .
In SQL Server Management Studio, expand the database where the procedure was created. Click Programmability , then click Stored Procedures . Within this Stored Procedures directory you will see all the procedures created for this bank. Right-click the name of the procedure that you want to see the code in, then select Script Stored Procedure as -> Modify .
If you want the text in a result cell, you can use this query :
select
[text]
from
sys.syscomments comm
inner join sys.procedures procs on procs.object_id = comm.id
where
procs.[name] = 'foo'
Just change foo
to the name of your procedure .
If you want the text to read, you can open a new query , press CTRL + T (this puts the query results in SSMS in text mode) and run:
exec sp_helptext 'foo'
Again, replace foo
with the name of your procedure .
Or you can go to: Server - > Databases - > your base - > Programmability - > Stored Procedures
... Right-click on the procedure and then click Modify . So you can even change and save your procedure.
The command can be used:
sp_heltptext 'nomeCompletoDaProcedure'
This causes Procedure
to return as records in the view part of table
in DB. Home
If you do not want the return as records you can use Ctrl + T before execution to return the value as text as mentioned by the user Renan in the comments of that response.