Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Environment - SQL Server

RSS
Modified on Fri, Oct 29, 2010, 3:33 PM by Administrator Categorized as SQL Server, SSRS (SQL Server Reporting Services)

SQL Code

The following SQL will return the environment (SQL Server Instance + Database Name) in which it runs; for example: [MyServer\MyInstance].[MyDatabase].

{copytext|div1}
select
     Environment    = '[' + convert(varchar(300), serverproperty('servername')) 
                                + '].[' + db_name() + ']'

Using in a Report

1. Create a new dataset in your report called Environment, which uses the same data source as your main dataset and is based on the above SQL statement.

Environment Dataset

Environment Dataset


2. Create a new report parameter called Environment. Make it hidden and set its default value to the Environment field in the Environment dataset.

Environment Report Parameter

Environment Report Parameter


3. Create a textbox in the page footer of your report (or wherever you like) and set its value to =Parameters!Environment.Value. Also, setting the font size to 6-point seems to be a good size.

  Name Size
- EnvironmentDataset.png 12.78 KB
- EnvironmentParameter.png 28.26 KB

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2018, Patrick Jasinski.