0

Using execute process task in SSIS ,I am trying to execute a batch file which is having script as :

sqlcmd  -S ServerName -d DataBasName  -Q "EXECUTE store_procedure_name"%1    -o C:\Users\Desktop\exe_test\abc.txt   -s "," -W 

%1 passes arguments to store procedure. And I have used expressions to pass argument by using a variable in argument property.

Variable have an expression as :

"'"+(DT_WSTR, 20)@[User::v_ST_DT]+"'"+","+"'"+(DT_WSTR, 20)@[User::v_ED_DT] +"'"+","+(DT_WSTR, 20)@[User::v_ST_Key] +","+(DT_WSTR, 20)@[User::v_END_SCFL_LOAD_KEY]

Execute process task is executing very well. But in my abc.txt file I am getting statement as :

"Msg 105, Level 15, State 1, Server ServerName, Line 1
Unclosed quotation mark after the character string ''@[User::v_ST_DT]
'. "

for the @[User::v_ST_DT] value is 1/1/1900 3:23:00 PM.

Please help me in resolving this. Many Thanks in Advance!!

sorrell
  • 1,801
  • 1
  • 16
  • 27

1 Answers1

0

I could be missing something, but I believe that in order to pass variables to a stored procedure in a sqlcmd line you must use the /v argument. Some resources: How do I call a stored procedure with arguments using sqlcmd.exe?

https://msdn.microsoft.com/en-us/library/ms188714.aspx

Community
  • 1
  • 1
TPhe
  • 1,681
  • 2
  • 11
  • 20