Using Environment variables in T-SQL

前端 未结 6 1824
独厮守ぢ
独厮守ぢ 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:24

    To "read the value of a system environment variable in a T-SQL script" you can set SQL Management Studio to use "sqlcmd Mode".

    Then you can use like this:

    Print '$(TEMP)'
    
    :r $(Temp)\Member.sql
    go
    

    I'm not sure how this is done outside of "SQL Management Studio" but it should be hard to find out.

提交回复
热议问题