0

I have the following SQL Command in an OLE DB Source, in a data flow task:

Select Top 5000 * 
From ProcessHistory.ScribeDeadZone1
Where ScribeDeadZoneId > ?

At the moment this works fine. However, I'd like to replace the 5000 with a variable. I can't seem to get the syntax right because everything I try results in an error when I click the Parameters button to set the parameter. I've tried

Select Top ? * and Select Top (?) *. Is this possible to do?

5
  • Just an idea, could you not build a variable with the entire SQL statement and then use the SQL Command from Variable option? Commented Jan 29, 2016 at 14:15
  • @Gareth - Yes I could and I'm actually working in that direction until I get a firm answer to my post. Commented Jan 29, 2016 at 14:20
  • Gareth's comment IS the answer, and I was going to post it as such until I saw his comment. His suggestion is the only way to do what you want. Firm enough? : ) Commented Jan 29, 2016 at 14:43
  • @TabAlleman - Yes, and if someone wants to post this as an answer, I'll accept it. Commented Jan 29, 2016 at 14:45
  • If @Gareth doesn't get to it later today, I will. Commented Jan 29, 2016 at 14:46

1 Answer 1

1

You need to build the SQL statement in a variable and then use the SQL Command from Variable option when defining the data source.

Sign up to request clarification or add additional context in comments.

1 Comment

Can someone please give a bit more detail as to what is meant by building the SQL statement in a variable? When I choose SQL Command from Variable, the parameter button disappears and it says my query has a syntax error (I'm guessing from the question mark).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.