Monday 10 July 2017

sp_helptext not working with schema SQL Server 2016

While I was trying to fetch procedure syntax in SQL server using sp_helptext I was unable to fetch the same, because procedure was created under different schema myschema instead of dbo.

sp_helptext myprocedure
Msg 15009, Level 16, State 1, Procedure sp_helptext, Line 54 [Batch Start Line 3]
The object 'myprocedure' does not exist in database 'dbname' or is invalid for this operation.

sp_helptext myschema.myprocedure
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near '.'.

Then I tried execution with single quote
sp_helptext 'myschema.myprocedure'

working :-)