Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Problems with parameters

Author  Topic 

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2013-11-28 : 10:06:56
I'm having a very elementary problem with parameters passed to an Execute SQL Task:

I have two parameters defined at the package level:

1. Input, type int32, value 1
2. Output type int32, value 0

In my task, I map the variable Input to the Parameters, direction input, type LONG, name 0.

Then in the Reslt Set, I define the variable Output, result name 0.

I put in a simple query:

Select 1


And set the result set to Single Row.

I added a script task afterwards to show the results in a message box.

I run the package and it works. I see '1' in the messagebox.

Now, the trouble begins! I changed the query to:

select ?


and used the same parameter and result set mappings. This time, however, the task fails with the error message:

quote:
[Execute SQL Task] Error: Executing the query "select ?" failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.


I'm totally stuck! Since the simpe 'select 1' works fine, I think I can rule out the suggestions regarding the resultset or connection. That leaves the parameters. I just can't see what the issue can be.

Any help would be greatly appreciated.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2013-11-28 : 16:27:47
More info on this:

From [url]http://technet.microsoft.com/en-us/library/cc280502.aspx[/url]

quote:

SELECT, INSERT, UPDATE, and DELETE commands frequently include WHERE clauses to specify filters that define the conditions each row in the source tables must meet to qualify for an SQL command. Parameters provide the filter values in the WHERE clauses.



What this does NOT say is that you cannot substitute parameters anywhere else! Not even in a case statement (wouldn't that be nice?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-29 : 00:50:38
its working fine for me

see attached pkg. just change the connection to your server and db and test

https://drive.google.com/file/d/0B4ZDNhljf8tQUnVveVlzZHhWa3M/edit?usp=sharing

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2013-11-29 : 08:45:59
quote:
Originally posted by visakh16

its working fine for me

see attached pkg. just change the connection to your server and db and test




turns out the problem was the property ByPassPrepare was set to False. it was failing before the query was sent to the server!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-30 : 01:48:03
quote:
Originally posted by gbritton

quote:
Originally posted by visakh16

its working fine for me

see attached pkg. just change the connection to your server and db and test




turns out the problem was the property ByPassPrepare was set to False. it was failing before the query was sent to the server!



ok that explains it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -