Files
DP44/DataPRO_sql/dbo.sp_DBImportMMEDirections.StoredProcedure.sql
2026-04-17 14:55:32 -04:00

75 lines
3.3 KiB
Transact-SQL
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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