Use SQL Script Parameter to Map Drive I am trying to map a drive to a UNC path where the UNC Path is a variable, but I keep getting an error saying:


  Incorrect syntax near '+'


I execute this script:

DECLARE @UNCSourcePath nvarchar(255) = '\\OTHER_SERVER\C$\Program Files'
EXEC xp_cmdshell 'NET USE S: ' + @UNCSourcePath


Any idea what the syntax should be?
It looks like it only accepts one argument. So try doing this...

DECLARE @UNCSourcePath nvarchar(255) = 'NET USE S: "\\OTHER_SERVER\C$\Program Files"'  
EXEC xp_cmdshell @UNCSourcePath