Results 1 to 3 of 3

Thread: getting environment variable value from SP Code

  1. #1
    Join Date
    Feb 2007
    Posts
    8

    getting environment variable value from SP Code

    Hi,

    I want to get the value of an environment variable which is set by command prompt of operating system like

    start -> run -> cmd

    set myname=Mahendra

    i want to use this environment variable myname in my Stored procedure of sql server 2005.


    Please advise.

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    There is no direct way to do that, but you can do this

    create table #output (output varchar(255))

    insert into #output exec master..xp_cmdshell 'set'

    select output from #output where output like '%windir%'

    Or

    you could use xp_regread procedure to read HKEY_CURRENT_USER key values.

  3. #3
    Join Date
    Feb 2007
    Posts
    8
    Thanks for your quick reply..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •