title: How to Pass Multi Value strings as single parameter to BCP query in sql server
body: <p>here am facing problem to pass multivalues parameter to bcp query.</p>
  
  <p>In my scenario parameters are  </p>
  
  <pre><code>@CustomFieldsHeaders ='CS Check','CS Date','CS Drop','CS Radio','RSP Text','RSP Date','RSP Check','RSP radio','RSP Drp','DOB'  
  </code></pre>
  
  <p>I need to pass the above as a single parameter.</p>
  
  <p>Following is my query for reference, please help</p>
  
  <pre><code>  DECLARE @CustomFieldsHeaders AS VARCHAR(MAX)
          SELECT @CustomFieldsHeaders = COALESCE(@CustomFieldsHeaders+',' ,'') + ''''+CAST(FieldName as varchar(max))+''''  FROM ManageFields
          PRINT @CustomFieldsHeaders
  
  
          DECLARE @CustFieldNames VARCHAR(MAX)
          SELECT @CustFieldNames =''+ COALESCE(@CustFieldNames+',' ,'') + CAST(ContactFieldName as varchar(max))+''
          from ManageFields
          print  @CustFieldNames
  
     DECLARE @SQL AS VARCHAR(8000) 
     DECLARE @StoredProcedure AS VARCHAR(8000) 
       SET @StoredProcedure=N'"EXEC  QA31_28thNov2013.dbo.GetAllRecsBasedOnListIds_BCPTest_1 117, NULL, '+@CustFieldNames+', '''+@CustomFieldsHeaders+''' " '         
          SET @SQL = N'bcp '+@StoredProcedure + ' queryout '+'D:\BCP_WEBREPORT\QA_v1_23rdSep2013\BounceReport\12-07-13\TESTREPORT13.CSV'  +' -c -t, -S PSPL-06 -Usa -Psa!2013'  
          PRINT @SQL 
          EXEC MASTER..XP_CMDSHELL @SQL 
  </code></pre>