26

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.

4 Answers 4

54

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'
0
1

sp_helptext [dbname.spname] try this

1
  • This is the same answer, with less detail, as the accepted answer from over a decade ago. What’s the benefit to repeating it? When you have a bit more reputation around Stack Overflow, you’ll be able to upvote answers you found useful as a way of validating them. Feb 16, 2021 at 18:36
0

Little addition in answer if you have different user rather then dbo then do like this.

EXEC  [ServerName].[DatabaseName].dbo.sp_HelpText '[user].[storedProcName]'
-1

It's the correct way to access linked DB:

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

But make sure to mention dbo as it owns the sp_helptext.

1
  • 5
    Regurgitating a correct answer with minor nuances is bad form. Please add to the correct answer's comment or construct a unique answer other than the one('s) provided.
    – GoldBishop
    Aug 31, 2015 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.