May 2, 2012

sp_MSadd_log_shipping_error_detail (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_MSadd_log_shipping_error_detail(uniqueidentifier @agent_id
, tinyint @agent_type
, int @session_id
, nvarchar @database
, int @sequence_number
, nvarchar @message
, nvarchar @source
, nvarchar @help_url)

MetaData:

 create procedure sys.sp_MSadd_log_shipping_error_detail   
(
@agent_id uniqueidentifier -- primary/secondary ID
,@agent_type tinyint -- 0 = Backup, 1 = Copy, 2 = Restore
,@session_id int
,@database sysname = NULL -- primary/secondary database
,@sequence_number int
,@message nvarchar(4000) = N'No message specified'
,@source nvarchar(4000) = N'No source specified'
,@help_url nvarchar(4000) = N'No help_url specified'
)
as
begin
set nocount on
declare @retcode int
,@agent_idstring sysname
,@curdate datetime
,@curutcdate datetime
,@monitor_server sysname
,@monitor_server_security_mode int
--
-- security check
--
exec @retcode = sys.sp_MSlogshippingsysadmincheck
if (@retcode != 0 or @@error != 0)
return 1
--
-- must be invoked from master db
--
if (db_name() != N'master')
begin
raiserror(5001, 16,-1)
return 1
end
--
-- validate agent_type
--
if (@agent_type not in (0,1,2))
begin
raiserror(21055, 16, -1, '@agent_type','sp_MSadd_log_shipping_error_detail')
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
--
-- set the dates
--
select @curdate = getdate()
,@curutcdate = getutcdate()
--
-- get monitor server information
--
if (@agent_type = 0)
begin
select @monitor_server = monitor_server
,@monitor_server_security_mode = monitor_server_security_mode
from msdb.dbo.log_shipping_primary_databases
where primary_id = @agent_id
end
else
begin
select @monitor_server = monitor_server
,@monitor_server_security_mode = monitor_server_security_mode
from msdb.dbo.log_shipping_secondary
where secondary_id = @agent_id
end
--
-- add error record for monitoring
--
exec @retcode = sys.sp_MSprocesslogshippingmonitorerror
@mode = 1
,@agent_id = @agent_id
,@agent_type = @agent_type
,@session_id = @session_id
,@sequence_number = @sequence_number
,@monitor_server = @monitor_server
,@monitor_server_security_mode = @monitor_server_security_mode
,@database = @database
,@log_time = @curdate
,@log_time_utc = @curutcdate
,@message = @message
,@source = @source
,@help_url = @help_url
if (@retcode != 0 or @@error != 0)
goto UNDO
--
-- all done
--
return 0

UNDO:
return 1
end

No comments:

Post a Comment

Total Pageviews