覲
ALTER PROCEDURE [dbo].[AddEvent]
@EventType nvarchar (260),
@EventData nvarchar (260)
AS
insert into [Event]
([EventID], [EventType], [EventData], [TimeEntered], [ProcessStart], [BatchID])
values
(NewID(), @EventType, @EventData, GETUTCDATE(), NULL, NULL)
ALTER PROCEDURE [dbo].[AddEvent]
@EventType nvarchar (260),
@EventData nvarchar (260)
AS
--Subject Update
declare
@title nvarchar(200)
if object_id('tempdb.dbo.#x') is not null
drop table #x
select convert(xml, ExtensionSettings) x
into #x
from Subscriptions
where SubscriptionID = @EventData
select
@title = [yyyy-mm-dd_format] + '(' + weekday_name_jp + ')'
from dm.common.dim_date
where date_key = convert(date, getdate()-1)
select @title = substring(Value, 1, charindex(':', Value)) + ' ' + @title
from (
select
y.item.value('(Name)[1]', 'nvarchar(50)') Name
, y.item.value('(Value)[1]', 'nvarchar(50)') Value
from #x x
cross apply x.x.nodes('/ParameterValues/ParameterValue') as y(item)
) t
where Name = 'Subject'
--print @title
update #x
set x.modify('replace value of (/ParameterValues/ParameterValue[Name="Subject"]/Value/text())[1] with (sql:variable("@title"))')
update a
set ExtensionSettings = (select convert(ntext, convert(nvarchar(max), x)) from #x)
from Subscriptions a
where a.SubscriptionID = @EventData
--Add Event
insert into [Event]
([EventID], [EventType], [EventData], [TimeEntered], [ProcessStart], [BatchID])
values
(NewID(), @EventType, @EventData, GETUTCDATE(), NULL, NULL)