Friday, January 27, 2012

multiple schema report

tnx in advance for any help.
I have a multiple enterprise system in which every enterprise is being
modeled as a schema in the DB. This means that schemas are identical in
structure and when you connect to one schema, you are connecting to one
logical enterprise.
Now, I need to write a bunch of reports with the ability to connect
indiferently to on Enterprise or another (the user selects against which
Enterprise he wants to run the report to).
RS allows to define one or more Datasets for every report. But that has to
be an SQL instruction with schema qualifying "hardcoded" for every table you
use.
I've thought about dynamic SQL inside a stored procedure, and the enterprise
(schema) being passed as a parameter, but that's not such an elegant
solution.
So any suggestion will be gratefully welcome...
regardsIn RS 2005 you can base a data source on an expression. This sounds like
your scenario is exactly what this feature was put in for.
From Books Online:
Data Source Expressions
You can put an expression into a connection string to allow users to select
the data source at run time. For example, suppose a multinational firm has
data servers in several countries. With an expression-based connection
string, a user who is running a sales report can select a data source for a
particular country before running the report.
The following example illustrates the use of a data source expression in a
SQL Server connection string. The example assumes you have created a report
parameter named ServerName:
Copy Code
="data source=" & Parameters!ServerName.Value & ";initial
catalog=AdventureWorks
Data source expressions are processed at run time or when a report is
previewed. The expression must be written in Visual Basic. Use the following
guidelines when defining a data source expression:
a.. Design the report using a static connection string. A static
connection string refers to a connection string that is not set through an
expression (for example, when you follow the steps for creating a
report-specific or shared data source, you are defining a static connection
string). Using a static connection string allows you to connect to the data
source in Report Designer so that you can get the query results you need to
create the report.
b.. When defining the data source connection, do not use a shared data
source. You cannot use a data source expression in a shared data source. You
must define a report-specific data source for the report.
c.. Specify credentials separately from the connection string. You can use
stored credentials, prompted credentials, or integrated security.
d.. Add a report parameter to specify a data source. For parameter values,
you can either provide a static list of available values (in this case, the
available values should be data sources you can use with the report) or
define a query that retrieves a list of data sources at run time.
e.. Be sure that the list of data sources shares the same database schema.
All report design begins with schema information. If there is a mismatch
between the schema used to define the report and the actual schema used by
the report at run time, the report might not run.
f.. Before publishing the report, replace the static connection string
with an expression. Wait until you are finished designing the report before
you replace the static connection string with an expression. Once you use an
expression, you cannot execute the query in Report Designer. Furthermore,
the field list in the Datasets window and the Parameters list will not
update automatically.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Edmundo J. Davila" <edavila@.monisa.com> wrote in message
news:19A56F20-96FE-4751-846F-9E8B2D5CF689@.microsoft.com...
> tnx in advance for any help.
> I have a multiple enterprise system in which every enterprise is being
> modeled as a schema in the DB. This means that schemas are identical in
> structure and when you connect to one schema, you are connecting to one
> logical enterprise.
> Now, I need to write a bunch of reports with the ability to connect
> indiferently to on Enterprise or another (the user selects against which
> Enterprise he wants to run the report to).
> RS allows to define one or more Datasets for every report. But that has to
> be an SQL instruction with schema qualifying "hardcoded" for every table
> you
> use.
> I've thought about dynamic SQL inside a stored procedure, and the
> enterprise
> (schema) being passed as a parameter, but that's not such an elegant
> solution.
> So any suggestion will be gratefully welcome...
> regards
>
begin 666 copycode.gif
M1TE&.#EA#P`/`.9F`).BM[+"V*[$\(&NY:Z_U'.AWER,VIBKQBE4JIFLQ_S]
M_LO/U)*P[8JN_,73\JFXSF2%R=;>[/;Y_>OO]BM7L6Z<VB)&CZ:]["!!AJ"Y
M[VB7U9RPSM+;\9>FNZ.RR"-(EOGZ_")%CIRKP;+)\*[0_Z^^U#5EQ2E4K*FY
MSX*?V,_9YM+6W9JMRFZ7YV".Y\S7[-'ZINOS)"JX+K:_^KO^R5,FR=0HIJN
MRI:FN^;J\^#F\25-G25*F+_+W=+>\,#*X,+.Y/7V^[K%U/O]_B-'DG^G\_#T
M^\?2X7.2T4=NNI_%^B%#B=OD]_?X^Z_#[?#R^)>IQ*K![XZX\"%#BIRUYZ*Q
MQV:"I?#S^*.RQYJNS*O"[]/>]55YP2I7LW*:ZH6GZR=0I%MRC[[.\#5)8U&#
MT?_______P``````````````````````````````````````````````````
M`````````````````````````````````````````````````"'Y! $``&8`
M+ `````/``\```>?@.&:"@.X2%AH>"`0$$! \>*X@.!99-E558+AR64"CA"89B%
M*&4S)#X``EI1&0P,+X)8DR!/.0*495\F0&8B94I2`P47MEXC%#\="D$3.A%4
M90T-'"Y=)V `3< 5&C*41DP.63L`5S J1STI944M!F1D-SP`8_/S2&5#-%MB
F3@.E$AA!EVKDC<R"$(2X2-L1@.D> `E"6&DB! 8*/&!PM3, 0"`#L`
`
end|||Hello Edmundo,
Have you got the the problem sorted? I am having the same trouble. In my
case, I need to select a db schema at the run time. Here are methods I've
tried:
1. create a parameter to contain the db name. Add in the ODBC connection
string "database=Parameters!db_name.Value", this doesnt work. The alert
"database-Parameters!db_name.Value doesn't exist" turns up.
2. delete the "database = XXX" part from the connection string, so no
specific database in the DB server will be connected, a connection to the DB
server itself is established. create a parameter to contain the db name. in
the query use ?.attr_name=XXX. By doing this, I expect the parameter can
specify the DB name at the run time. this doesnt work either.
So if you have the solution, could you please post it up. It'll be really
appreciated!
cheers,
P
"Bruce L-C [MVP]" wrote:
> In RS 2005 you can base a data source on an expression. This sounds like
> your scenario is exactly what this feature was put in for.
> From Books Online:
> Data Source Expressions
> You can put an expression into a connection string to allow users to select
> the data source at run time. For example, suppose a multinational firm has
> data servers in several countries. With an expression-based connection
> string, a user who is running a sales report can select a data source for a
> particular country before running the report.
> The following example illustrates the use of a data source expression in a
> SQL Server connection string. The example assumes you have created a report
> parameter named ServerName:
> Copy Code
> ="data source=" & Parameters!ServerName.Value & ";initial
> catalog=AdventureWorks
> Data source expressions are processed at run time or when a report is
> previewed. The expression must be written in Visual Basic. Use the following
> guidelines when defining a data source expression:
> a.. Design the report using a static connection string. A static
> connection string refers to a connection string that is not set through an
> expression (for example, when you follow the steps for creating a
> report-specific or shared data source, you are defining a static connection
> string). Using a static connection string allows you to connect to the data
> source in Report Designer so that you can get the query results you need to
> create the report.
>
> b.. When defining the data source connection, do not use a shared data
> source. You cannot use a data source expression in a shared data source. You
> must define a report-specific data source for the report.
>
> c.. Specify credentials separately from the connection string. You can use
> stored credentials, prompted credentials, or integrated security.
>
> d.. Add a report parameter to specify a data source. For parameter values,
> you can either provide a static list of available values (in this case, the
> available values should be data sources you can use with the report) or
> define a query that retrieves a list of data sources at run time.
>
> e.. Be sure that the list of data sources shares the same database schema.
> All report design begins with schema information. If there is a mismatch
> between the schema used to define the report and the actual schema used by
> the report at run time, the report might not run.
>
> f.. Before publishing the report, replace the static connection string
> with an expression. Wait until you are finished designing the report before
> you replace the static connection string with an expression. Once you use an
> expression, you cannot execute the query in Report Designer. Furthermore,
> the field list in the Datasets window and the Parameters list will not
> update automatically.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Edmundo J. Davila" <edavila@.monisa.com> wrote in message
> news:19A56F20-96FE-4751-846F-9E8B2D5CF689@.microsoft.com...
> > tnx in advance for any help.
> >
> > I have a multiple enterprise system in which every enterprise is being
> > modeled as a schema in the DB. This means that schemas are identical in
> > structure and when you connect to one schema, you are connecting to one
> > logical enterprise.
> >
> > Now, I need to write a bunch of reports with the ability to connect
> > indiferently to on Enterprise or another (the user selects against which
> > Enterprise he wants to run the report to).
> >
> > RS allows to define one or more Datasets for every report. But that has to
> > be an SQL instruction with schema qualifying "hardcoded" for every table
> > you
> > use.
> >
> > I've thought about dynamic SQL inside a stored procedure, and the
> > enterprise
> > (schema) being passed as a parameter, but that's not such an elegant
> > solution.
> >
> > So any suggestion will be gratefully welcome...
> >
> > regards
> >
>
>

No comments:

Post a Comment