DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
 
 
SITE SEARCH SQLUSA.com VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
How to read an environment variable?

The following Microsoft SQL Server T-SQL code sample demonstrate how to read a Windows environment variable.

-- Display all environment variables

EXEC master..xp_cmdshell 'set'

------------

 

-- Retrieve a single environment variable - Read environment variable

DECLARE @EnvVar nvarchar(256)

CREATE TABLE #Upload(EnvVar nvarchar(256))

INSERT INTO #Upload

EXEC xp_cmdshell 'echo %USERDOMAIN%'

DELETE #Upload WHERE EnvVar is NULL OR EnvVar = ''

SET @EnvVar = (SELECT EnvVar from #Upload)

SELECT @EnvVar as [User Domain]

/* User Domain

ENTERPRISE */

DROP TABLE #Upload

------------

 

Related link: Setting Environment variables

 

 

Exam Prep 70-461
SQL 2016 DESIGN & PROGRAMMING
 
 
 
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE