0

我在存储过程中使用选择拆分函数来传递多选 IDS,如下所示。

SELECT     Status AS ClientInbox, COUNT(submitTime) AS CountStatus
        FROM         dbo.ClientInbox with (nolock) join debtor with (nolock) on ClientInbox.debtorid = debtor.id
        WHERE      (submitTime >= @fromDate and submittime <= @toDate)
         and debtor.clientid IN  (SELECT ID FROM [dbo].[split_IDs] (@clientid,','))
        GROUP BY Status 

其中 [dbo].[split_IDs] 是一个函数。我的问题是在测试时,当我用一组像 ('1,2,3,4,5') 这样的设置来复制变量 @clientid 时,查询会返回所需的记录。但是当我从 VS 运行该过程时,它不会返回确切的记录。我尝试通过在 SQL 服务器中执行如下过程来找出问题所在

USE [Volare_2005]
GO

DECLARE @return_value int
DECLARE @fromDate datetime
DECLARE @toDate datetime

EXEC    @return_value = [dbo].[GetSMSReportDate]
        @fromDate = '2000-04-06T12:23:45',
        @toDate =  '2013-10-22T21:10:12',
        @option = 0 ,
        @collectorid = 0,
        @supervisorid = 0,
        @clientid = N'95,1'

--SELECT    'Return Value' = @return_value

GO

它也无法返回记录。但是,当我通过在过程中复制变量 @clientid 来运行查询时,它工作正常。我不确定我是不是出错了。请任何帮助将不胜感激

4

0 回答 0