75 lines
3.3 KiB
Plaintext
75 lines
3.3 KiB
Plaintext
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_DBImportMMEDirections]') AND type in (N'P', N'PC'))
|
|
DROP PROCEDURE [dbo].[sp_DBImportMMEDirections]
|
|
GO
|
|
SET ANSI_NULLS ON
|
|
GO
|
|
SET QUOTED_IDENTIFIER ON
|
|
GO
|
|
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_DBImportMMEDirections]') AND type in (N'P', N'PC'))
|
|
BEGIN
|
|
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_DBImportMMEDirections] AS'
|
|
END
|
|
GO
|
|
ALTER PROCEDURE [dbo].[sp_DBImportMMEDirections]
|
|
@MMEDirections xml
|
|
,@errorNumber int output
|
|
,@errorMessage nvarchar(250) output
|
|
AS
|
|
BEGIN
|
|
|
|
|
|
begin try
|
|
begin transaction tMMEDirections
|
|
select
|
|
t.x.value('(./s_GUID)[1]', 'nvarchar(50)')
|
|
,t.x.value('(./DIRECTION)[1]', 'nvarchar(50)')
|
|
,t.x.value('(./TEXT_L1)[1]', 'nvarchar(50)')
|
|
,t.x.value('(./TEXT_L2)[1]', 'nvarchar(50)')
|
|
,t.x.value('(./DATE)[1]', 'datetime')
|
|
,t.x.value('(./VERSION)[1]', 'int')
|
|
,t.x.value('(./EXPIRED)[1]', 'bit')
|
|
,t.x.value('(./REMARKS)[1]', 'nvarchar(50)')
|
|
,t.x.value('(./LAST_CHANGE)[1]', 'datetime')
|
|
,t.x.value('(./LAST_CHANGE_TEXT)[1]', 'nvarchar(50)')
|
|
,t.x.value('(./HISTORY)[1]', 'nvarchar(50)')
|
|
,t.x.value('(./SORTKEY)[1]', 'nvarchar(50)')
|
|
from @MMEDirections.nodes('/CustomDirections/CustomDirection') t(x)
|
|
OPTION (OPTIMIZE FOR ( @MMEDirections = NULL ))
|
|
|
|
commit transaction tMMEDirections
|
|
end try
|
|
begin catch
|
|
set @errorNumber = error_number()
|
|
set @errorMessage = error_message()
|
|
rollback transaction tMMEDirections
|
|
end catch;
|
|
END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GO
|