Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display SQL Server Name in Report Footer

Status
Not open for further replies.

BilldCon

Technical User
Jan 10, 2003
5
US
Does anyone have any idea of the best way to AUTOMATICALLY have the name of the SQL server(s) that are providing data to a Crystal Report appear in the report footer of a report? I am using 8.5, and I cannot for the life of me find a Crystal or Basic Syntax statement that will accomplish this goal, so I've recently turned to using the SQL expression tool. I've tried creating a SQL expression named "sql_SERVER_NAME(S)" with the following as the contents of the expression:

SELECT @@SERVERNAME

This does not work - does anyone know of a way that this expression can be modified to work in CR 8.5, or of another way to pass server name information to the report footer?

(right now I am manually putting server name information in the report comments and then inserting that field - talk about clumsy.)

Thanks in advance!
 
Thanks for the suggestion - I have one (hopefully) final question. Should @@SERVERNAME be the only thing entered into the SQL expression? I have tried this, and it does not display any information in the report when it is printed or displayed on screen (although it does not give me an error - progress!).

Thanks again for your help!
 
You might also try:

CONVERT(char(20), SERVERPROPERTY('servername'))

And yes, you don't want to add in a select, a SQL Expression adds th element to the select generated by CR, so if you stated SELECT, you'd end up with:

select table.field1, table.field2, table.field3, select @@servername

Which would cause errors.

-k kai@informeddatadecisions.com
 
Still no luck - I think I might be facing a permissions issue - I am checking with our DBA right now...thanks so much for your time and help!
 
It IS NOT a permissions issue - I can perform the query in QA using the same username and password I use to log on to the DB with Crystal.

Any other ideas? Is there some simple syntax I can place in the SQL expression that will return information (so I can test to see if ANYTHING will work)? Please send the complete text of what should be in the SQL expression and where I should drag - and - drop the SQL expression field to get it to display.

Thanks in advance!
 
using northwind DB

SELECT CustomerID, CompanyName, ContactName, @@ServerName as ServerName
FROM Customers
 
Thanks everyone - your help is very appreciated, and, while I still cannot display the information I am after, I think our investigation has uncovered problems that are preventing me from getting to the information in question, and it is now up to our DBA to find the answers.

Again, thanks for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top