April 17, 2012

sp_control_plan_guide (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_control_plan_guide(nvarchar @operation
, nvarchar @name)

MetaData:

 create procedure sys.sp_control_plan_guide  
@operation nvarchar(60),
@name sysname = NULL
as
BEGIN TRANSACTION

declare @return_code int

if( lower(@operation) = 'drop' OR lower(@operation) = 'enable' OR lower(@operation) = 'disable')
exec @return_code = sys.sp_control_plan_guide_int @operation, @name
else
exec @return_code = sys.sp_control_plan_guide_int @operation


if( @return_code = 0 )
begin
if( lower(@operation) = 'drop' OR lower(@operation) = 'drop all')
begin
EXEC %%System().FireTrigger(ID = 238, ID = 27, ID = 0, ID = 0, Value = @name,
ID = -1, ID = 0, ID = 0, Value = NULL, ID = 2,
Value = @operation, Value = @name, Value = NULL, Value = NULL, Value = NULL, Value = NULL, Value = NULL)
end
else
begin
EXEC %%System().FireTrigger(ID = 216, ID = 27, ID = 0, ID = 0, Value = @name,
ID = -1, ID = 0, ID = 0, Value = NULL, ID = 2,
Value = @operation, Value = @name, Value = NULL, Value = NULL, Value = NULL, Value = NULL, Value = NULL)
end
end

COMMIT TRANSACTION

No comments:

Post a Comment

Total Pageviews