Friday, February 24, 2012

Dynamic Tablename

Hi,
Maybe a simple Question
I have a Dataset with following SQL Command:
SELECT a.*, b.stelleText
FROM verkauf_leas200510 a LEFT OUTER JOIN
Vregion_stelle b ON a.stellelevel = b.stelleLevel AND
a.stellekey = b.stelleKey
WHERE (a.stellelevel = @.pStelleLevel) AND (a.stellekey = @.pStelleKey)
ORDER BY a.stellelevel, a.stellekey, a.sort
Is it possible to change theTablename (verkauf_leas200510 ) also
dynamically, maybe also with a parameter like in the where-clause
Have not found a solution yet, because i want to generate a report with the
tablename as parameter.
Thanks in advance
DieterIf you can use a stored procedure as a datasource for the report you can
solve the problem by creating dynamic SQL.
The Proc will have 3 parameters:
@.Tablename
@.pStelleLevel
@.pStelleKey
And in the proc you will dynamically create the select statement
Grtz,
Nico
"Dieter Felix" wrote:
> Hi,
> Maybe a simple Question
> I have a Dataset with following SQL Command:
> SELECT a.*, b.stelleText
> FROM verkauf_leas200510 a LEFT OUTER JOIN
> Vregion_stelle b ON a.stellelevel = b.stelleLevel AND
> a.stellekey = b.stelleKey
> WHERE (a.stellelevel = @.pStelleLevel) AND (a.stellekey = @.pStelleKey)
> ORDER BY a.stellelevel, a.stellekey, a.sort
> Is it possible to change theTablename (verkauf_leas200510 ) also
> dynamically, maybe also with a parameter like in the where-clause
> Have not found a solution yet, because i want to generate a report with the
> tablename as parameter.
> Thanks in advance
> Dieter|||Table name is not a problem. However, you need to have the field names
returned stay the same. To do this have the query tool in generic mode. Then
you put in an expression
="select * from " & parameters!TableName.value
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Dieter Felix" <Dieter Felix@.discussions.microsoft.com> wrote in message
news:6D6DE04F-8F74-418E-9EB2-E32E7437F0E1@.microsoft.com...
> Hi,
> Maybe a simple Question
> I have a Dataset with following SQL Command:
> SELECT a.*, b.stelleText
> FROM verkauf_leas200510 a LEFT OUTER JOIN
> Vregion_stelle b ON a.stellelevel = b.stelleLevel AND
> a.stellekey = b.stelleKey
> WHERE (a.stellelevel = @.pStelleLevel) AND (a.stellekey = @.pStelleKey)
> ORDER BY a.stellelevel, a.stellekey, a.sort
> Is it possible to change theTablename (verkauf_leas200510 ) also
> dynamically, maybe also with a parameter like in the where-clause
> Have not found a solution yet, because i want to generate a report with
> the
> tablename as parameter.
> Thanks in advance
> Dieter

No comments:

Post a Comment