title: Stored procedure passing guids as CSV string
body: <p>Call of stored procedure</p>
  
  <pre><code>exec spBatchRequestsForRescreening @GuidList='''A2C4B17A-57A7-49A9-97A0-0000070D92F3'',''945FA383-17D4-4CCB-B8FD-00000A40E2DC'''
  </code></pre>
  
  <p>fails with
  "Conversion failed when converting from a character string to uniqueidentifier."</p>
  
  <p>Stored procedure</p>
  
  <pre><code>ALTER PROC [dbo].[spBatchRequestsForRescreening] (@GuidList varchar(8000) )
  AS BEGIN
      select *
      from DeniedPartyTransactions.dbo.DpsRequest
      with (nolock)
      where C1_PK in ( @GuidList )
  END
  </code></pre>
  
  <p>Statement below works. Is there way for macro substitution of CSV of Guids in single quotes. </p>
  
  <pre><code>select * from DpsRequest
  where c1_PK in ( 'A2C4B17A-57A7-49A9-97A0-0000070D92F3','945FA383-17D4-4CCB-B8FD-00000A40E2DC' ) 
  </code></pre>
  
  <p>Update: </p>
  
  <p>Below does work. Maybe there is anything better ?</p>
  
  <pre><code>ALTER PROC [dbo].[spBatchRequestsForRescreening] (@GuidList varchar(7000) )
  AS BEGIN
      DECLARE @SQL varchar(8000)
      SET @SQL = 
      'select *
      from DeniedPartyTransactions.dbo.DpsRequest
      with (nolock)
      where C1_PK in (' +  @GuidList + ')' ;
      EXEC(@SQL)    
  END
  </code></pre>