Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL using sp_HelpText to view a stored procedure on a linked server

Tags:

Anyone have an idea about how to use sp_helptext to view a stored procedure on a linked server? basically something like this. I don't have the credentials to that linked server to look at it.

EXEC sp_HelpText '[ServerName].[DatabaseName].dbo.storedProcName' 

thanks ahead.

like image 271
stevenjmyu Avatar asked Jun 01 '10 21:06

stevenjmyu


People also ask

How do I find Stored Procedures in linked server?

Using SQL Server Management StudioIn Object Explorer, connect to an instance of Database Engine and then expand that instance. Expand Databases, expand the database in which the procedure belongs, and then expand Programmability. Expand Stored Procedures, right-click the procedure and then click View Dependencies.

Can you call a stored procedure on a linked server?

Both stored procedures and distributed queries are allowed against linked servers; however, only stored procedures are allowed against remote servers.

How do I view a stored procedure in SQL Server query?

Using SQL Server Management StudioExpand Stored Procedures, right-click the procedure and then select Script Stored Procedure as, and then select one of the following: Create To, Alter To, or Drop and Create To. Select New Query Editor Window. This will display the procedure definition.

How can we access stored procedure in SQL Server?

In Object Explorer, connect to an instance of the SQL Server Database Engine, expand that instance, and then expand Databases. Expand the database that you want, expand Programmability, and then expand Stored Procedures. Right-click the user-defined stored procedure that you want and select Execute Stored Procedure.


2 Answers

Instead of invoking the sp_helptext locally with a remote argument, invoke it remotely with a local argument:

EXEC  [ServerName].[DatabaseName].dbo.sp_HelpText 'storedProcName' 
like image 176
Remus Rusanu Avatar answered Sep 18 '22 14:09

Remus Rusanu


sp_helptext [dbname.spname] try this

like image 38
Sarath Kumar pgm Avatar answered Sep 18 '22 14:09

Sarath Kumar pgm