all groups > sql server dts > june 2005 >
You're in the

sql server dts

group:

Retrieving Data from a database, filtered by a local Table


Re: Retrieving Data from a database, filtered by a local Table Ross Presser
6/29/2005 5:03:20 PM
sql server dts:
[quoted text, click to view]

Re: Retrieving Data from a database, filtered by a local Table Allan Mitchell
6/29/2005 10:25:49 PM
A number of ways really but here is my preferred way

Use an ExecuteSQL task to get those filter values and put them into Global
Variables.

With those variables if your source provider accepts it you can now use the
values in the SourceSQL Statement property of the datapump task by using
this method

1. Use ? as a placeholder in the statement (select ... FROM ... WHERE col =
?) and using the parameters button map onto the ? , a global variable

If not then you can still do this

1. Use an active Script task to dynamically build the SourceSQLStatement.

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

--



Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - You thought DTS was good. here we show you the new stuff.
www.konesans.com - Consultancy from the people who know


[quoted text, click to view]

Retrieving Data from a database, filtered by a local Table muc80339 NO[at]SPAM mnet-online.de
6/29/2005 10:59:10 PM
Hello,
i want to get data from a table, but only the data that is specified
(dynamically) with a filter that is stored in a local table.

SQL-Statement
SELECT * FROM external_table1
INNER JOIN internal_table2 ON table1.datafield1 = table2.datafield2

How do I get this in my dts-package if i only can have one reference to
external_table1?

Thankx.

Frank

Re: Retrieving Data from a database, filtered by a local Table muc80339 NO[at]SPAM mnet-online.de
6/30/2005 12:00:00 AM
I will try today with the global variable, I think the upload is not
possible because the source system is a SAP System.

"Ross Presser" <rpresser@NOSPAMgmail.com.invalid> schrieb im Newsbeitrag
news:j0zm98knmzl2.1gmlhcmwi7w56.dlg@40tude.net...
[quoted text, click to view]

Re: Retrieving Data from a database, filtered by a local Table Frank Mayer
6/30/2005 2:41:17 PM
Thnx.
I did as you described, but I have now the problem that my Table contains
more than one value.
What do I have to do with:

SELECT.... WHERE col IN ?

It reports Access Violation...

[quoted text, click to view]

Re: Retrieving Data from a database, filtered by a local Table Allan Mitchell
6/30/2005 8:55:07 PM
You can't do it like this

You will need to build up your statement then if you want to use IN

Here is an article theat will get you cooking

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

--



Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - You thought DTS was good. here we show you the new stuff.
www.konesans.com - Consultancy from the people who know


[quoted text, click to view]

Re: Retrieving Data from a database, filtered by a local Table Frank Mayer
7/1/2005 1:03:44 PM
Hello,
thanks.

Problem is still:
sSQLStatement = "SELECT PSPNR, PSPID, POST1, POSKI, POSID FROM PROJ WHERE
PSPID IN (SELECT Filter_Projects FROM Flt_Proj)"

OR

sSQLStatement = "SELECT PSPNR, PSPID, POST1, POSKI, POSID FROM PROJ WHERE
PSPID IN ('" & DTSGlobalVariables("FilterProject") & "')"
The GlobalVariable contains a rowset of a SQL Statement that is executed
before...

Errors ( I Think)
Possibility 1 the sub-query does not contain data --> no datarecords chosen
Possibility 2 Error-Message Type mismatch



[quoted text, click to view]

AddThis Social Bookmark Button