Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I need to import excelsheet data to sqlserver table using ssis. For this I am using one stored procedure and a parameter for the stored procedure as "@path".
I am passing this path from frontend file uploader. Now, when I am calling my package from stored procedure, it is giving error as "The File option cannot be specified with the DTS, SQL, Server, User, or Password options".
I searched, but I am not getting anything. Please help me. My code is:
SQL
--exec execpackage '\D:\jyothi\personal\Book1.xlsx'
ALTER PROCEDURE [dbo].[execpackage]
(
	-- Add the parameters for the stored procedure here
	@path varchar(max) 
)
AS
BEGIN
	declare @ssisstr varchar(8000)
	declare @packagename varchar(200)
	declare @servername varchar(100)
     declare @params varchar(8000)
----my package name
set @packagename = 'D:\jyothi\personal\excelsheet2\excelsheettype\Package1.dtsx'
----my server name
set @servername = 'YIITUSER1\SQL1'

---- please make this line in single line, I have made this line in multiline 
----due to article format.
----package variables, which we are passing in SSIS Package.
set @params = '/set \Package.Variables[path].Value];"\"'+@path+'\""'

----now making "dtexec" SQL from dynamic values
--set @ssisstr = 'dtexec /sq ' + @packagename + ' /ser ' + @servername + ' '
set @ssisstr = 'dtexec /f "D:\jyothi\personal\excelsheet2\excelsheettype\Package1.dtsx" /ser '+@servername+' /connection "\"Data Source=YIITUSER1\\SQL1;IntegratedSecurity=True;
           Initial Catalog=excel;Provider=SQLNCLI.1;Persist Security Info=True;
           Auto Translate=False;\"" '
set @ssisstr = @ssisstr + @params
-----print line for verification 
print @ssisstr

----
----now execute dynamic SQL by using EXEC. 
DECLARE @returncode int
EXEC @returncode = xp_cmdshell @ssisstr
select @returncode
END

In SSIS package, I am taking dft task in control flow and excelsource,dataconversion,oledb destination in data flow environment.
Here I used two variables as package variables for dynamically passing path to excelsource and for giving sheet name.

Please help me
Posted
Updated 24-Jan-11 2:15am
v2
Comments
Slacker007 24-Jan-11 11:13am    
There is some info on this subject via Google. Did you try searching the internet first?

1 solution

I think you do not need to specify the connection string while calling the package. It will take the connection details from the current context or it should be specified in the package itself.

If you want to specify a connection string, you should specify name as well. Here[^] is some help.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900