0
votes

i have a SP which is accepting file name as parameter.

This SP i want to call through Execute SQL Task In SSIS (using 2008)

But my problem is each time filename is got changed. how to handle this kind of scenerio.

Please help me, as i am pretty new to SSIS

SP

CREATE PROCEDURE [dbo].[Xml_FULL_insert]

@XMLFileName NVARCHAR(256)

AS

BEGIN

SET NOCOUNT ON
SET XACT_ABORT ON

BEGIN TRY

DECLARE @Query NVARCHAR(max)

IF OBJECT_ID('dbo.tblFile', 'U') IS NOT NULL DROP TABLE dbo.tblFile;

CREATE TABLE dbo.tblFile (xmldata XML)

BEGIN TRANSACTION

SET @Query = 'INSERT INTO tblFile(XMLData) SELECT CONVERT (XML, 
BulkColumn,2) FROM OPENROWSET( BULK '''+@XMLFileName+''', SINGLE_BLOB) AS     
x;'

 EXEC (@Query) 


COMMIT TRANSACTION

END TRY

END

i followed the below step:-

  1. declare variable with full file path in a value. (Variable Name: Filename )

  2. calling SP from Execute SQL TASK EXEC [Xml_FULL_insert] ?

  3. PARAMETER Passing :

Variable name: Filename Direction: Input Dtattype VARCHAR Parameter Name: 0 length: 50

whenever filename is differ than the specified in the value of variable, the package failed.

Though file structure is same.

my variable have value (D:\SSIS_Packages\AutoGrade.xml) full path where file name is ACES_2015.10_AutoGrade.xml and in a same folder new file appear as mynewfile.xml. package fail inspite of parameter mapping

do i need to do some changes in SP? Please suggest if possible.

1
U will need working with User variables which pass value to parameter of stored procedure . Check this link simple-talk.com/sql/ssis/… - Mudassir Hasan
@mhasan: in my sql statement i have passed like EXEC dbo.Xml_FULL_insert ? In Parameter mapping Variable name: Filename Direction: Input Dtattype VARCHAR Parameter Name: 0 length: 50 in variable Path: D:\SSIS_Packages*.xml still getting error like. "ResultSet" property not set correctly, parameters not set correctly. Please help - akhrot
May anyone please help me on this. - akhrot
Is there a reason you limit it to 50 characters in SSIS, but allow 256 characters in SQL? Are any of the file names (including the full path) you are passing longer than fifty characters? - AHiggins

1 Answers

0
votes

change the parameter name from parameter0 to the actual variable name in the ssis package example in your case it should be this varible name:filename
so in your parameter mapping change it from parameter0 to @filename.