What causes it to be legal to pass an object name to the system stored procedure sp_helptext
?
What mechanism converts the object name to a string?
e.g.
-- works
sp_helptext myproc
sp_helptext [myproc]
sp_helptext [dbo.myproc]
-- and behaves the same as a string
sp_helptext 'myproc'
sp_helptext 'dbo.myproc'
sp_helptext [dbo.myproc]
-- does not work
sp_helptext dbo.myproc -- Msg 102, Level 15, State 1, Line 1 incorrect syntax near '.'
-- an additional case that does not work.
sp_helptext [dbo].[myproc] -- Msg 102, Level 15, State 1, Line 1 incorrect syntax
It seems odd that I'm not required to single quote valid proc names, unless it has a .
separating schema name and procedure name. I'm looking for an explanation of how it gets auto converted from a quoted name to a string literal to be passed as the value of the parameter.
I don't have a specific issue to resolve; I am simply inquisitive about things that aren't documented.