0
votes

Anybody know how to show a database server name on crystal report. I am using crystal report X, store procedure as data source to crystal report.

If you use view then you can use SQL expression field to display server name using, select SERVERPROPERTY('servername') select @@SERVERNAME

But how can we do it using stored procedure (as SQL Expression filed is not avialable in this datasource in crystal report).

Thanks in advance.

3

3 Answers

0
votes

If you are just trying to pass the Database Name through the stored procedure so that it is available in Crystal Reports you could do it by declaring the variable and adding it to the Select Query like this.

Alter PROCEDURE SelectSomeRecords 
AS
BEGIN
SET NOCOUNT ON;


Declare @DatabaseName varchar(25) 
Set @DatabaseName = (SELECT DB_NAME())


Select  top 10 LastName
        , FirstName 
        , @DatabaseName as DatabaseName
from    Customers

END
GO

This may be a hack way to do it but I haven't found a way to do it similar to the way you do with a SQL Expression.

0
votes

i done it by adding extra command data source on report. I think this only way you can do it if you are using SP as your data source in report.

0
votes

I know this post is old but wasn't able to find the answer anywhere when I was looking previously.

Add a command to report with the following SQL:

select sys_context('userenv','db_name') from dual

Do not link it to anything in your existing tables