May 15, 2012

sp_MSgetdbversion (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_MSgetdbversion()

MetaData:

 --   
-- Name:
-- sp_MSgetdbversion
--
-- Description:
-- Retrieves the guid restore version value and converts it to a nearly unique int.
--
-- Parameters:
-- See the procedure definition.
--
-- Returns:
-- 0 - succeeded
-- 1 - failed
--
-- Result:
-- None
--
-- Security:
-- Called by dist agents (must be made public).
-- SYSADMIN or DBO of db
-- Requires Certificate signature for catalog access
--
create procedure sys.sp_MSgetdbversion
(
@current_version int output
)
as
begin
declare @retcode int,
@currentGuid uniqueidentifier

-- Security Check
if is_srvrolemember('sysadmin') != 1
and is_member ('db_owner') != 1
begin
raiserror (21050, 16, -1)
return 1
end

select @currentGuid = recovery_fork_guid
from sys.database_recovery_status
where database_id = db_id()
if @@error <> 0
return 1

select @current_version = substring(convert(binary(16), isnull(@currentGuid, 0x0)),1,6)

return 0
end

No comments:

Post a Comment

Total Pageviews