Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Server Reporting Services, RDL and Windows Environment Variable

Posted on 2016-08-23
4
Medium Priority
?
100 Views
Last Modified: 2016-08-29
If I define a variable in the OS like:

SET MyTest="Hello"

Is it possible and if so, how, to get that MyTest variable value into an RDL of SSRS? It's on SQL Server 2014.

It is possible to do like a variable of %MyTest% from within the RDL?

Thanks in advance for the information
0
Comment
Question by:davism
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:DcpKing
ID: 41769701
If you can grant the reporting system the permissions, the code that gathers the data before feeding it to the report (I personally prefer backing reports with stored procedures rather than embedded queries, as they're lots easier to maintain) can use xp_cmdshell to run code to obtain the information you seek. Then run some PowerShell to push it back into SQL Server.
In fact, you should be able to embed PowerShell into your report - see here for some info.

Hope this helps

Mike
0
 
LVL 1

Author Comment

by:davism
ID: 41770240
I prefer NOT allowing xp_cmdshell possibilities from within SQL. SQL should not interact with the DBMS except for maybe DBA need/use.  A CLR is a better option than xp_cmdshell.

Why would the reporting system need permissions to access the environments variables? It would be read-only.
0
 
LVL 16

Accepted Solution

by:
DcpKing earned 2000 total points
ID: 41770386
I was referring to the id of the runner of the proc supplying data to the report. However, I also found the CodePlex link that shows something of running SSRS with PowerShell, which might be easier to use to get the environment value variable and produce data accordingly for the report ... I haven't had a chance to try any of this, though (sorry!).

Mike
0
 
LVL 1

Author Closing Comment

by:davism
ID: 41775355
Thanks Mike! Great information.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
The article covers five tools all IT professionals should know about, as they up productivity by a great deal!
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question