Servername in middle of unc path

  • mtz676

    SSCrazy Eights

    Points: 8893

    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

  • MVDBA (Mike Vessey)

    SSC-Insane

    Points: 21184

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

    MVDBA

  • mtz676

    SSCrazy Eights

    Points: 8893

    I tried that . it’s not working

  • DesNorton

    SSC-Insane

    Points: 22848

    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 4 (of 4 total)

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