May 14, 2012

sp_MSget_log_shipping_new_sessionid (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_MSget_log_shipping_new_sessionid(uniqueidentifier @agent_id
, tinyint @agent_type)

MetaData:

 create procedure sys.sp_MSget_log_shipping_new_sessionid   
(
@agent_id uniqueidentifier -- primary/secondary ID
,@agent_type tinyint -- 0 = Backup, 1 = Copy, 2 = Restore
,@session_id int output
)
as
begin
set nocount on
declare @retcode int
,@agent_idstring sysname

--
-- security check
--
exec @retcode = sys.sp_MSlogshippingsysadmincheck
if (@retcode != 0 or @@error != 0)
return 1
--
-- validate agent_type
--
if (@agent_type not in (0,1,2))
begin
raiserror(21055, 16, -1, '@agent_type','sp_MSget_log_shipping_new_sessionid')
return 1
end
--
-- validate agent
--
if (sys.fn_MSvalidatelogshipagentid(@agent_id, @agent_type) = 0)
begin
select @agent_idstring = cast(@agent_id as sysname)
raiserror(32016, 16, 1, @agent_idstring, @agent_type)
return 1
end
--
-- get the current session id
--
select @session_id = isnull(max(session_id),0) + 1
from msdb.dbo.log_shipping_monitor_history_detail
where agent_id = @agent_id and agent_type = @agent_type
--
-- all done
--
return 0
end

No comments:

Post a Comment

Total Pageviews