HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlModerate

Sp_helptext Error

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
errorsp_helptextstackoverflow

Problem

I am using sp_helptext to list some stored procs instead of going through the ui. I am having a problem with the naming convention we have chosen to adopt.

I have a stored proc nameed [Test.FooBar].

Execute sp_helptext [Test.FooBar]



Msg 15009, Level 16, State 1, Procedure sp_helptext, Line 54 The
object 'Test.FooBar' does not exist in
database 'Foo' or is invalid for this
operation.

When I change the exceut statement to be fully qualified i get a different error

Execute sp_helptext [Foo].[dbo].[Test.FooBar]


Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.


Can one someone point me in the right direction to fix this. Thank you very much.

Solution

Maybe try:

EXEC Foo..sp_helptext 'dbo.[Test.FooBar]';


Still having problems with sp_helptext? Ok, stop using it - it's not the only way to get the object's definition.

SELECT OBJECT_DEFINITION(OBJECT_ID('dbo.[Test.FooBar]'));


Next, please stop putting . and other special characters within object names.

Code Snippets

EXEC Foo..sp_helptext 'dbo.[Test.FooBar]';
SELECT OBJECT_DEFINITION(OBJECT_ID('dbo.[Test.FooBar]'));

Context

StackExchange Database Administrators Q#2501, answer score: 11

Revisions (0)

No revisions yet.