On SQL2005 and trying to load an XML file into a table column of XMLtype
with variable file name. The result is the xml column is null
USE [PS_RS_DEV]
GO
/****** Object: StoredProcedure [dbo].[ps_create_rentals] Script Date:
08/27/2013 18:00:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[ps_create_rentals1]
@xmlfile varchar(40)
AS
/******************************************************************************
** File: ps_create_rentals.sql
** Name: ps_create_rentals
** Desc: Stored Procedure
**EXEC ps_create_rentals 'D-RE-1-07252013040105'
**
********************************************************************************/
SET NOCOUNT ON
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
DECLARE
@sql NVARCHAR(MAX),
@inputPath VARCHAR(255),
@inputFile VARCHAR(40),
@requestType VARCHAR(45)
SET @inputFile = @xmlfile + '.xml'
--SET @inputFile = 'A-RE-1-03232013012346.xml'
SET @inputPath = 'D:\DE_OPS\DE_Trans\Inbound\Decrypted\'
SET @requestType = 'CreateRentalContractRequest'
SET @sql = N'INSERT INTO dbo.TRXN_Load_Raw(RawData, LoadedDateTime,
RequestType, InputFile)
SELECT CONVERT(XML, BulkColumn) AS BulkColumn, GETDATE(),
''' + @requestType + ''',''' + @inputFile + '''
FROM OPENROWSET(BULK ''' + @inputPath + @inputFile + ''',
SINGLE_BLOB) AS x;'
print @inputFile
print @xmlfile
print @sql
EXECUTE sp_executesql @sql
No comments:
Post a Comment