![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Thanks for taking the time to read this. I am trying to set a global variable equal to a rs. I loop through the values and insert a comma, so my global variable value looks like (#####,#####), However, when it's fed to the source sql, it doesn't work. Now if I only have a single value in my variable it works just great. Can I not do this? Thanks for any thought's. BCL |
#3
| |||
| |||
|
|
So you build your statement right? Like what does the resultant statement look? Follow this article Global Variables and SQL statements in DTS (http://www.sqldts.com/default.aspx?205 "BCL" <BCL (AT) discussions (DOT) microsoft.com> wrote in message news:BCL (AT) discussions (DOT) microsoft.com: Hi, Thanks for taking the time to read this. I am trying to set a global variable equal to a rs. I loop through the values and insert a comma, so my global variable value looks like (#####,#####), However, when it's fed to the source sql, it doesn't work. Now if I only have a single value in my variable it works just great. Can I not do this? Thanks for any thought's. BCL |
#4
| |||
| |||
|
|
So you build your statement right? yes Like what does the resultant statement look? Select * where field in ? My GV = 12345,23456 "Allan Mitchell" wrote: So you build your statement right? Like what does the resultant statement look? Follow this article Global Variables and SQL statements in DTS (http://www.sqldts.com/default.aspx?205 "BCL" <BCL (AT) discussions (DOT) microsoft.com> wrote in message news:BCL (AT) discussions (DOT) microsoft.com: Hi, Thanks for taking the time to read this. I am trying to set a global variable equal to a rs. I loop through the values and insert a comma, so my global variable value looks like (#####,#####), However, when it's fed to the source sql, it doesn't work. Now if I only have a single value in my variable it works just great. Can I not do this? Thanks for any thought's. BCL |
#5
| |||
| |||
|
|
As a guide, if you cannot use a local variable in SQL, then it will not work with global variables in DTS, so this would fail- DECLARE @Fred varchar(100) SET @fred = 'ddd,ggg' SELECT * FROM table WHERE field IN @Fred To solve this in SQL you would dynamic SQL. The link Alan posted is the equivalent in DTS "BCL" <BCL (AT) discussions (DOT) microsoft.com> wrote in message news:F3065547-273F-496B-B5B3-55EA184C6E26 (AT) microsoft (DOT) com... So you build your statement right? yes Like what does the resultant statement look? Select * where field in ? My GV = 12345,23456 "Allan Mitchell" wrote: So you build your statement right? Like what does the resultant statement look? Follow this article Global Variables and SQL statements in DTS (http://www.sqldts.com/default.aspx?205 "BCL" <BCL (AT) discussions (DOT) microsoft.com> wrote in message news:BCL (AT) discussions (DOT) microsoft.com: Hi, Thanks for taking the time to read this. I am trying to set a global variable equal to a rs. I loop through the values and insert a comma, so my global variable value looks like (#####,#####), However, when it's fed to the source sql, it doesn't work. Now if I only have a single value in my variable it works just great. Can I not do this? Thanks for any thought's. BCL |
#6
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |