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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

db name and server name

Status
Not open for further replies.

mart10

MIS
Nov 2, 2007
394
GB
I am using cr 2016

I need to bring into report header the server name and database name. I thought it maybe a Special Field but it isn't

So how do I capture this . I login via OLE DB (ADO) Sql server connection route btw
 
Depends on database this works for MS SQL.

In Crystal Reports, open the report based off a MS SQL Server database, on which you want to display the database name.
In the Field Explorer pane, right click on "SQL Expression Field", and select "New..."
Type a name for the SQL Expression Field, and click "OK"

In the SQL Expression Field window. create a select based on this query depending on set up use Servername or Machine name
SELECT SERVERPROPERTY('ServerName'), SERVERPROPERTY('MachineName'), DB_NAME()

Save and close the SQL Expression Field.
Add the SQL Expression Field on the report to display the database name.

Ian
 
If you are using a command just add above select to your main query.
Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top