May 29, 2012

sp_MSSetServerProperties (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_MSSetServerProperties(int @auto_start)

MetaData:

   
create proc sys.sp_MSSetServerProperties
@auto_start INT = NULL -- 1 or 0, while 1 = auto start, 0 = manual start
as
set nocount on

-- only sysadmins are allowed to execute this stored procedure
if( is_srvrolemember(N'sysadmin') = 0 )
begin
RAISERROR (15003, -1, -1, N'sysadmin')
return 1
end

-- Make sure values (if supplied) are good
IF (@auto_start IS NOT NULL)
BEGIN
-- NOTE: When setting the the services start value, 2 == auto-start, 3 == Don't auto-start
SELECT @auto_start = CASE @auto_start
WHEN 0 THEN 3
WHEN 1 THEN 2
ELSE 3 -- Assume non auto-start if passed a junk value
END
END

-- Write out the values
IF (@auto_start IS NOT NULL)
BEGIN
IF ((PLATFORM() & 0x1) = 0x1) -- NT
EXECUTE sys.xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
N'SYSTEM\CurrentControlSet\Services\MSSQLServer',
N'Start',
N'REG_DWORD',
@auto_start
ELSE
RAISERROR(14546, 16, 1, '@auto_start')
END

No comments:

Post a Comment

Total Pageviews