Search code examples
sql-serverdefaultsql-server-profiler

What does default mean in some sql server profiler sql window?


I ran the sql server profiler and for one sql statemnt I can see the following script:

declare @p9 varchar(8000)
set @p9=NULL
declare @p10 smallint
set @p10=default
declare @p11 bit
set @p11=default
declare @p12 int
set @p12=default
exec spgConfigValue @FullKey='System|MessageLog|Record|SSRS',@Key1=default,@Key2=default,@Key3=default,@Key4=default,@Key5=default,@DataType=default,@DefaultValue='True',@Value=@p9 output,@RecordExistsFlag=@p10 output,@ValueBit=@p11 output,@ValueInt=@p12 output,@PortalStudentID=default,@PortalUserID=default
select @p9, @p10, @p11, @p12

This question is just out of curiosity.I can conceptually understand what set @p10=default mean in the context. I think it means because there is no value are set when executing the proc in application for that output param, just use the default value inside the proc for that param. What I don't understand though is the way this script is written. If you run the whole script inside management studio it generates error Incorrect syntax near the keyword 'default'. So what is happening here? Is what SQL Server generates in this case just a sudo-code and the actual code is something else or this is really the code that somehow gets run in SQLServer execution engine?


Solution

  • With an RPC request, the batch text you see in a profiler trace is actually reverse-engineered from the TDS protocol stream rather than the actual batch text sent by the application. You are correct that this is basically pseudo-code, and in this case, the syntax isn't valid for execution as an ad-hoc query.