How to access the code behind a Stored Procedure?

3

How can I access the code behind a stored procedure ? Home I am using Microsoft SQL Server Management Studio .

    
asked by anonymous 30.06.2017 / 21:47

3 answers

7

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 .

    
30.06.2017 / 21:56
4

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.

    
30.06.2017 / 21:56
2

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.

    
30.06.2017 / 22:02