Showing posts with label dear. Show all posts
Showing posts with label dear. Show all posts

Tuesday, March 27, 2012

Dynamic report

Dear all,
I want to create a dynamic report so that I can change some field quickly.
For example: in future, if Field {Report ID} on report header is replaced by {Running User ID}. How can I do once for all reports.
Many thanksWill this work? The idea is to only maintain data in the table.

1. setup a database table that contains user-id and names etc.
2. create a string variable in the report for display.
3. write a routine to detect for the requires condition and pull data off the table.
4. for each report, plug in the same codes created in step-2.

Hope it works for you.

Dynamic Reference to Linked Server

Dear all
I got a problem that I would like to use a dynamic statement to query data
from a linked server (it is not guaranteed that the used database remains on
this server or the Test-Database would be renamed).
I tried to use the OPENQUERY-Functionality or to set up a SP which uses
Parameters
Example (SP with OPENQUERY)I:
ALTER PROCEDURE sp_GetParameterTable
@.LnkSrv NVARCHAR(30), @.LnkTbl NVARCHAR(30)
AS
SELECT
*
FROM
OPENQUERY
(
LTRIM(@.LnkSrv), -- LinkedServer
'
SELECT
*
FROM ' +
LTRIM(@.LnkTbl)
+ '
WHERE
(X_TYPE = ''XYZ'')
ORDER BY
CONVERT(FLOAT,X_KEY) DESC
'
)
->> it won't work !!
the other way to use a a SELECT Statement and a Function to get the Table
won't also not work.
SELECT
TOP 1
CONVERT(FLOAT,X_KEY) AS LastUsedKey
FROM
lokalserver.dbo.fn_Test
(
LinkedServer,
DataBase,
Table
)
WHERE
(X_TYPE = 'XYZ')
ORDER BY
CONVERT(FLOAT,X_KEY) DESC
-->> Function
ALTER FUNCTION fn_Test
(
@.SrvName NVARCHAR(20),
@.DBName NVARCHAR(20),
@.tblName NVARCHAR(35)
)
RETURNS NVARCHAR(80)
AS
BEGIN
DECLARE @.DBRef NVARCHAR(80)
SET @.DBRef = LTRIM(@.SrvName) + '.'
+ LTRIM(@.DBName ) + '.dbo.'
+ LTRIM(@.tblName )
RETURN(LTRIM(@.DBRef))
END
This will also not working.
Could anybody help me in this context? Any Help will be appreciated.
Youry,
BrunoSomething like this should work - I have used it:
DECLARE @.w nvarchar(4000)
SET @.w = 'SELECT.....FROM ['
IF (@.server IS NOT NULL) BEGIN SET @.w = @.w + @.server + '].[' END
SET @.w = @.w + @.database + ']..[' + @.table + ']...(rest of query)'
EXECUTE sp_executesql @.w
Cheers,
Peter.
Peter Hyssett
"Bruno" wrote:

> Dear all
> I got a problem that I would like to use a dynamic statement to query data
> from a linked server (it is not guaranteed that the used database remains
on
> this server or the Test-Database would be renamed).
> I tried to use the OPENQUERY-Functionality or to set up a SP which uses
> Parameters
> Example (SP with OPENQUERY)I:
> ALTER PROCEDURE sp_GetParameterTable
> @.LnkSrv NVARCHAR(30), @.LnkTbl NVARCHAR(30)
> AS
> SELECT
> *
> FROM
> OPENQUERY
> (
> LTRIM(@.LnkSrv), -- LinkedServer
> '
> SELECT
> *
> FROM ' +
> LTRIM(@.LnkTbl)
> + '
> WHERE
> (X_TYPE = ''XYZ'')
> ORDER BY
> CONVERT(FLOAT,X_KEY) DESC
> '
> )
> ->> it won't work !!
> the other way to use a a SELECT Statement and a Function to get the Table
> won't also not work.
>
> SELECT
> TOP 1
> CONVERT(FLOAT,X_KEY) AS LastUsedKey
> FROM
> lokalserver.dbo.fn_Test
> (
> LinkedServer,
> DataBase,
> Table
> )
> WHERE
> (X_TYPE = 'XYZ')
> ORDER BY
> CONVERT(FLOAT,X_KEY) DESC
> -->> Function
> ALTER FUNCTION fn_Test
> (
> @.SrvName NVARCHAR(20),
> @.DBName NVARCHAR(20),
> @.tblName NVARCHAR(35)
> )
> RETURNS NVARCHAR(80)
> AS
> BEGIN
> DECLARE @.DBRef NVARCHAR(80)
> SET @.DBRef = LTRIM(@.SrvName) + '.'
> + LTRIM(@.DBName ) + '.dbo.'
> + LTRIM(@.tblName )
> RETURN(LTRIM(@.DBRef))
> END
> This will also not working.
> Could anybody help me in this context? Any Help will be appreciated.
> Youry,
> Bruno

Wednesday, March 7, 2012

Dynamic database connectivity?

Dear SSIS experts,

I was wondering if there's such a thing that we could assign the database connection on the fly dynamically? so that I save the connection string or the database name somewhere and SSIS reads it on load time or something..

Thank you

Yes! Look into "package configurations." Examples and more information are in BOL and all over this forum.|||Thanks for ur quick reply; however, I can't find a thing! would u plz give me a link or something? Thanks Smile|||Pull up Google and type in (without the quotes) "ssis package configurations"

The first few links should work very nicely for you.

The official page from Microsoft: http://msdn2.microsoft.com/en-us/library/ms141682.aspx

Sunday, February 26, 2012

Dynamic Crystal Report

Dear All,
How can I populate a data report using a Sqlquery.
Thanks in Advance
DanaCreate a stored procedure with that query and design the report using that procedure