sp_executesql -- one of the most important tool
Declare @killstatement nvarchar(10) --- note sp-executesql only accepts nvarchar
Begin
set @killstatement = 'KILL ' + cast(@session_id as varchar(3))
exec sp_executesql @killstatement
when some function expects uniqueidentifier keys but wont allow any parameter or variable
for example kill 69
you can not pass variable containing 69
for example @mnop nvarchar(5)
@mnop = 69
kill @mnop -- will be wrong
or kill '@mnop' -- will be wrong
the only way possible is above way using sp_executesql
Comments
Post a Comment