dbTalk Databases Forums  

parameterized query

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss parameterized query in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jeffrey
 
Posts: n/a

Default parameterized query - 12-17-2003 , 04:31 PM






In Execute SQL task, before the parameterized query, can I define some variable?
For example,
Declare @v1 uniqueidentifier
Declare @v2 uniqueidentifier

select @v1 = col1,
@v2 = col2
from table_name
where id = ?
.......(the left)

This can not be parsed in the Execute SQL task. What kind of limitation do we have
for the query inside this type of task?

Thanks.

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: parameterized query - 12-17-2003 , 04:59 PM






In article <F62607D3-D3F4-41E7-9755-B6E6A5A8213C (AT) microsoft (DOT) com>, Jeffrey
<anonymous (AT) discussions (DOT) microsoft.com> writes
Quote:
In Execute SQL task, before the parameterized query, can I define some
variable?
For example,
Declare @v1 uniqueidentifier
Declare @v2 uniqueidentifier

select @v1 = col1,
@v2 = col2
from table_name
where id = ?
.......(the left)

This can not be parsed in the Execute SQL task. What kind of limitation
do we have
for the query inside this type of task?

Thanks.
Unfortunately the syntax validation is quite annoyingly strict for
parameter queries.

Since the design time validation is even stricter than the run-rime,
sometimes you can work around this by using some dummy code at
design-time to set up your parameters, and then swap in the real code
through Disconnected Edit after the task has been closed. Obviously this
can be a real pain for ongoing maintenance in which case try the option
below.

If the run-time also fails you query, or for simplicity you prefer to
use a singe method, then the only option left is to manually handle the
parameters. Note this is really only any good for input parameters
though. See this sample-

Global Variables and SQL statements in DTS
(http://www.sqldts.com/default.aspx?205)
--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
Ilya Margolin
 
Posts: n/a

Default Re: parameterized query - 12-18-2003 , 07:22 AM



What I did in my case was creating a package variable to contain a sql
statement, constructing the statement in ActiveX task and swapping the
statement with dynamic properties task.

"Jeffrey" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
In Execute SQL task, before the parameterized query, can I define some
variable?
For example,
Declare @v1 uniqueidentifier
Declare @v2 uniqueidentifier

select @v1 = col1,
@v2 = col2
from table_name
where id = ?
......(the left)

This can not be parsed in the Execute SQL task. What kind of limitation do
we have
for the query inside this type of task?

Thanks.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.