dbTalk Databases Forums  

Retrieving Data from a database, filtered by a local Table

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


Discuss Retrieving Data from a database, filtered by a local Table in the microsoft.public.sqlserver.dts forum.



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

Default Retrieving Data from a database, filtered by a local Table - 06-29-2005 , 03:59 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



Reply With Quote
  #2  
Old   
Ross Presser
 
Posts: n/a

Default Re: Retrieving Data from a database, filtered by a local Table - 06-29-2005 , 04:03 PM






On Wed, 29 Jun 2005 22:59:10 +0200, muc80339 (AT) mnet-online (DOT) de wrote:

Quote:
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
Upload your local table to a #temp table?


Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Retrieving Data from a database, filtered by a local Table - 06-29-2005 , 04:25 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


<muc80339 (AT) mnet-online (DOT) de> wrote

Quote:
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




Reply With Quote
  #4  
Old   
 
Posts: n/a

Default Re: Retrieving Data from a database, filtered by a local Table - 06-30-2005 , 12:03 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 (AT) NOSPAMgmail (DOT) com.invalid> schrieb im Newsbeitrag
news:j0zm98knmzl2.1gmlhcmwi7w56.dlg (AT) 40tude (DOT) net...
Quote:
On Wed, 29 Jun 2005 22:59:10 +0200, muc80339 (AT) mnet-online (DOT) de wrote:

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

Upload your local table to a #temp table?



Reply With Quote
  #5  
Old   
Frank Mayer
 
Posts: n/a

Default Re: Retrieving Data from a database, filtered by a local Table - 06-30-2005 , 07:41 AM



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...

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
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


muc80339 (AT) mnet-online (DOT) de> wrote in message
news:d9v22s$98l$1 (AT) svr7 (DOT) m-online.net...
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






Reply With Quote
  #6  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Retrieving Data from a database, filtered by a local Table - 06-30-2005 , 02:55 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


"Frank Mayer" <frankmayer (AT) gmx (DOT) de> wrote

Quote:
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...

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:u5peVEPfFHA.1148 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


muc80339 (AT) mnet-online (DOT) de> wrote in message
news:d9v22s$98l$1 (AT) svr7 (DOT) m-online.net...
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








Reply With Quote
  #7  
Old   
Frank Mayer
 
Posts: n/a

Default Re: Retrieving Data from a database, filtered by a local Table - 07-01-2005 , 06:03 AM



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



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
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


"Frank Mayer" <frankmayer (AT) gmx (DOT) de> wrote in message
news:da0p9i$9nk$1 (AT) news (DOT) mch.sbs.de...
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...

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:u5peVEPfFHA.1148 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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


muc80339 (AT) mnet-online (DOT) de> wrote in message
news:d9v22s$98l$1 (AT) svr7 (DOT) m-online.net...
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










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.