Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Issue

Status
Not open for further replies.

rodeomount

Programmer
Sep 25, 2007
50
US

I'm trying to create a query I can use inside a DTS by dynamically setting the Query inside a dynamic properties task. Below is my select statement for creating the Select statement. I keep getting an error. It's mandatory that I use the query to load the values into the "IN" clause because this query will be run against an oracle db and the values I need in the "IN" clause are coming from SQL Server.

Select 'Select SVC_MS_REC_STS_CD,DTN_ARA_NO_PU_IR
from O858IA.VSVCPAK
where PKG_TCK_NR in (' + Select top 1000 TrackingNum from dbo.TEMP_TPSVCREQ order by TrackingNum + ')'
 
What is the error?

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
BTW- normally you declare a variable to hold the statement, then populate the variable with the statement.

Code:
DECLARE @sql VARCHAR(1000)
SET @sql = 'Select SVC_MS_REC_STS_CD,DTN_ARA_NO_PU_IR
from O858IA.VSVCPAK
where PKG_TCK_NR in (' + 'Select top 1000 TrackingNum from dbo.TEMP_TPSVCREQ order by TrackingNum' + ')''

EXEC (@sql)

Also, it appears you are missing some single quotes.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top