January 14, 2020 at 2:23 pm
I have an OLEDB Source that Id like to store the query in a table and set a variable with an EXEC SQL task and use that as the variable holding the query with oledb src set to SQL command from variable. The query will have parameters that Id like to pass in from the OLEDB Src's Parameters. Can this be done?
January 14, 2020 at 3:56 pm
Answered my own question. You cant do it that way. Also, you could use an expression task to replace placeholders in a query as long as the max length of the query is less than 4000. If its over 4000 I'm thinking the best bet is to store the query in a table and upon retrieving the query replace the placeholders with the values you need it to be before returning it.
January 14, 2020 at 5:58 pm
Answered my own question. You cant do it that way. Also, you could use an expression task to replace placeholders in a query as long as the max length of the query is less than 4000. If its over 4000 I'm thinking the best bet is to store the query in a table and upon retrieving the query replace the placeholders with the values you need it to be before returning it.
First, what makes you think there's some sort of limit at 4,000?
Also, simple place holder replacement does NOT prevent the possibility of SQL Injection. You need to sanitize anything being passed for place holder replacement.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 14, 2020 at 7:54 pm
If you need to dynamically create the SQL statement - here is one possibility:
The important part of this is that your stored procedure does not need to utilize dynamic SQL. It uses input parameters to read data from a configuration table and builds the SQL based on the rules you define - and you don't use any type of string manipulation based on the parameters, only based on the values you get from your configuration table.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply