title: Host-file colums may be skipped only when copying into the server
body: <p>I want to create a xml file from my database with bcp.</p>
  
  <p>The following code works in SQL Server 2008 but not in SQl Express 2005.</p>
  
  <p>This is the code error:
  <code>SQLState = S1000, NativeError = 0
  Error = [Microsoft][SQL Native Client] Host-file columns may be skipped only when copying into the Server</code></p>
  
  <p>These are Sql Express info:
  Microsoft SQL Server Management Studio Express: 9.00.4035.00</p>
  
  <p>Microsoft Data Access Components (MDAC): 2000.085.1132.00 (xpsp.080413-0852)</p>
  
  <p>Microsoft MSXML: 2.6 3.0 4.0 5.0 6.0</p>
  
  <p>Microsoft Internet Explorer 8.0.6001.18702</p>
  
  <p>Microsoft .NET Framework: 2.0.50727.3615</p>
  
  <p>SO: 5.1.2600</p>
  
  <p>This is my code:</p>
  
  <pre><code>DECLARE @FileName VARCHAR(150)
  DECLARE @dataExport AS DATETIME
  DECLARE @param VARCHAR(8)
  
  SET @FileName = 'c:\BackupSql\XMLOutput.xml'
  SET @dataExport = '20110122'
  SET @param = 'XXX'
  
  DECLARE @SQLCmd VARCHAR(1800)
  
  SELECT @SQLCmd = 'bcp ' + 
  '"DECLARE @xml as xml; ' +
  'DECLARE @text varchar(MAX); ' +             
  'SET @xml = (select ' +
  '(select ''' + convert(varchar(10), @dateExport, 112) + ''' as DateExport ' +
  'FOR XML PATH (''DATA''), TYPE), ' + 
  '(select ' +
      '(select Item as ITEM, cast(Quantity as int) as QTY, 
  convert(decimal(10,6), Price) as PRICE, ''0.0'' as TOTAL, convert(varchar(10), DateInv, 112) as DATE from '+ DB_NAME() +'.dbo.ITEMS where (ITEM not like ''X-%'' and ITEM not like ''Y-%'') and DateInv = ''' + convert(varchar(10), @dateExport, 112) + ''' ' +
          'FOR XML PATH(''LINE''), TYPE) ' +
      'FOR XML PATH(''BODY''), TYPE) ' +
      'FOR XML PATH (''''), ' +
      'ROOT(''MYROOT''), TYPE); ' +
  'SET @text = REPLACE(CAST(@xml AS varchar(max)), ''&gt;&lt;'', ''&gt;'' + CHAR(13) + CHAR(10) + ''&lt;''); ' +
  'SELECT @text" ' + 
  ' queryout ' +
  @FileName + ' -c -T -S' + convert(varchar(128), serverproperty('servername')) --Trustedonnection e ANSI
  
  EXECUTE master..xp_cmdshell @SQLCmd
  </code></pre>