存储过程的调用
exec spBatchRequestsForRescreening @GuidList='''A2C4B17A-57A7-49A9-97A0-0000070D92F3'',''945FA383-17D4-4CCB-B8FD-00000A40E2DC'''
失败并显示“从字符串转换为唯一标识符时转换失败。”
存储过程
ALTER PROC [dbo].[spBatchRequestsForRescreening] (@GuidList varchar(8000) )
AS BEGIN
select *
from DeniedPartyTransactions.dbo.DpsRequest
with (nolock)
where C1_PK in ( @GuidList )
END
下面的陈述有效。有没有办法用单引号对 Guid 的 CSV 进行宏替换。
select * from DpsRequest
where c1_PK in ( 'A2C4B17A-57A7-49A9-97A0-0000070D92F3','945FA383-17D4-4CCB-B8FD-00000A40E2DC' )
更新:
下面确实有效。也许有更好的东西?
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