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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.