Using Environment variables in T-SQL

前端 未结 6 1870
独厮守ぢ
独厮守ぢ 2021-01-18 16:31

How can I read the value of a system environment variable in a T-SQL script?

This is to run on SQL Server 2005.

6条回答
  •  死守一世寂寞
    2021-01-18 17:17

    This should give you a list (provided you allow people to execute xp_cmdshell)

    exec master..xp_cmdshell 'set'

    Note: xp_cmdshell is a security hazard ...

    You could also do this with a managed stored proc an extended stored proc or via a com component.

提交回复
热议问题