Servername in middle of unc path

  • How can I generate sqlservername in the middle of an UNC path?

    select N'\\ABCD\EFGH\IJKL\MNSP\("select @@servername")\AL.txt'

    If servername is MYSERVER then UNC path should be..

    Result should be \\ABCD\EFGH\IJKL\MNSP\MYSERVER\AL.txt

    Thanks

  • select N'\\ABCD\EFGH\IJKL\MNSP\'+ @@servername+'\AL.txt'

    MVDBA

  • I tried that . it’s not working

  • What didn't work?  How are we supposed to help you debug when you don't give us anything to work with?

    Perhaps you are looking for the machine name, and not the @@servername

    SELECT N'\\ABCD\EFGH\IJKL\MNSP\'
    + CONVERT( nvarchar(128), SERVERPROPERTY( 'MachineName' ))
    + N'\AL.txt';

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply