Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two Percent Signs in EXEC Statement

Tags:

sql

sql-server

In SQL Server 2014, the master database contains a system stored procedure called sp_rename. I was interested to know how it works, so I've been taking a look at it.

On line 190, there is an EXEC statement that contains two percent signs:

EXEC %%ScalarType(MultiName = @SchemaAndTypeName).LockMatchID(ID = 
@xusertype, Exclusive = 1)

What does the %% mean? I've searched around online, but haven't found anything that even remotely mentions it.

like image 828
ddavidd Avatar asked Oct 12 '17 13:10

ddavidd


1 Answers

Based off of this answer, it's an undocumented component of SQL Server. Basically, these are system commands that a typical user is not supposed to reference. Since you're looking at the components of a stored procedure, you'll see scripts that are normally inaccessible to a normal user.

Since the %% is (intentionally) undocumented it's difficult to determine exactly how the system is using it, but one can reasonably assume it's an indicator of system-only commands.

like image 131
PausePause Avatar answered Oct 24 '22 11:10

PausePause