title: Extended stored procedure xp_create_subdir returns "Invalid Parameter" message
body: <p>Since version 2005 Microsoft SQL Server allows creating path if it's not exist. Simply call stored procedure with parameter leading to desired path on disk.</p>
  
  <pre><code>DECLARE @targetDirectory nvarchar(max) = N'E:\backup' 
  exec xp_create_subdir @targetDirectory
  </code></pre>
  
  <p>So, if you write code above into query pane in Microsoft SQL Server Management Studio, you receive following error message:</p>
  
  <blockquote>
    <p>Msg 22048, Level 15, State 0, Line 0
    Error executing extended stored procedure: Invalid Parameter</p>
  </blockquote>
  
  <p>It's strange that if you change code to </p>
  
  <pre><code>exec xp_create_subdir N'E:\backup'
  </code></pre>
  
  <p>and execute it, directory is created at desired path, assuming that sql service account has rights to write.</p>