System.Data.SqlClient.SqlException:“in”附近的语法不正确

System.Data.SqlClient.SqlException:“in”附近的语法不正确,sql,stored-procedures,Sql,Stored Procedures,这是我的存储过程,我不知道它在哪里出错?请帮帮我…先谢谢你 这些是我嵌入到存储过程中的代码行,这些语句包含在关键字中 Declare @SQLQuery Nvarchar(1000) set @SQLQuery = ' select distinct program from tblProgNotes where Program in ' + @Program --print @SQLQuery create TABLE #T1 (

这是我的存储过程,我不知道它在哪里出错?请帮帮我…先谢谢你

这些是我嵌入到存储过程中的代码行,这些语句包含在关键字中

Declare @SQLQuery Nvarchar(1000)



         set  @SQLQuery = ' select distinct program from tblProgNotes where Program in ' + @Program

         --print @SQLQuery
         create TABLE #T1 ( Program int)
        insert  into #T1 execute sp_executesql @SQLQuery
并且@Program为null或p.Program在从T1选择程序中 最后一行嵌入在给定存储过程中的三个位置

并且@Program为null或p.Program在从T1选择程序中 这一行在给定的存储过程中嵌入了三次:我不知道它在哪里导致错误

            @StartDate DateTime,
            @EndDate DateTime,
            @ShowDollars bit = 0,
            @LateEntryOnly bit = 0, -- new
            @Status int = null, -- value of dropdown be locationid
            @Program nvarchar = null, -- value of dropdown be lookup codeID
            @Clinician int = null, -- value of tblProviders UserID
            @Billable int = 0

        As

        Declare @SQLQuery Nvarchar(1000)



         set  @SQLQuery = ' select distinct program from tblProgNotes where Program in ' + @Program

         --print @SQLQuery
         create TABLE #T1 ( Program int)
        insert  into #T1 execute sp_executesql @SQLQuery



        select B.ID as BillingCodeID, Code, B.MOD1, B.MOD2, RateAmount, StartDate, EndDate, POS, LicenseGroupID, Billable,ProviderID
        into #tmpRates
        from tblRates R 
        left join tblBillingCodes B on B.ID = R.BillingCodeID
        where PayorID = 1


        if @ShowDollars = 1
        Begin
        select distinct
        Isnull(U.LastName,'') + ', ' + IsNull(U.Firstname,'') as Clinician,
        p.DateOfService,
        P.PaceID,
        Dem.LastName + ', ' + Dem.FirstName as ClientName,
        P.ID as ProgressNoteID,
        PC.BillingCodeID,
        PC.ProgressNoteType,
        BC.Code, 
        PC.POS,
        BC.MOD1,
        BC.MOD2,
        Isnull(BC.Code,'') + ' ' + ISnull(PC.POS,'') + ' ' + ISNULL(BC.MOD1,'') + ' ' + ISNULL(BC.MOD2,'') as FullHCPC,
        PC.Units,
        PC.TimeIn,
        PC.TimeOut,
        DateDiff(mi,PC.TimeIn, PC.TimeOut) as Minutes,
        Case when Datediff(mi,PC.TimeIn,PC.TimeOut)/60 > 0 
        then Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut)/60) + 'h ' + Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' else Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' end as TimeDesc,
        I.BehavioralHealthCategory,
        case when p.DateOfService > '8/1/13' and PC.BillingCodeID in (3,4) and PC.DOCID is null then 'Log Missing' else convert(varchar(20),PC.DocID) end as TransportationLog,
        L3.Description as Program,
        P.LateEntry,
        case when PC.Billable = 0 then 'Non Billable' else '' end as NonBillable,
        (Convert(float,IsNull(R.RateAmount,0)) * case when PC.Units ='' then 0 else Convert(float,PC.Units) end) as 'Service Value',
        a.currentlocation as Status
        from tblProgNotes P
        left join tblProgressNoteCodes PC on PC.ProgressNoteID = P.ID and PC.ProgressNoteType = 1
        left join tblLicensure L on L.ProviderID = P.ClinicianID and L.[Primary] = 1 and P.DateOfService >= L.StartDate and (L.EndDate is null or L.EndDate >= P.DateOfService)
        left join tblLookups L2 on L2.Code = L.LicenseTypeID and L2.CategoryID = 48
        left join tblLookups L3 on L3.Code = P.Program and L3.CategoryID = 104
        left join #tmpRates R on R.BillingCodeID = PC.BillingCodeID and R.POS = PC.POS and R.LicenseGroupID = L2.Type and R.Billable = PC.Billable and R.ProviderID = P.Site
             and R.StartDate <= p.DateOfService and R.EndDate >= p.DateOfService
        left join tblBillingCodes BC on BC.ID = PC.BillingCodeID
        left join tblDemographics Dem on Dem.PaceID = P.PaceID
        left join tblIntakes I on I.ID = P.IntakeID
        left join tblReferrals CR on CR.ID = I.ReferralID
        left join tblProviders PP on PP.ID = P.ClinicianID
        left join vwUsers U on U.ID = PP.UserID
        left join tblactivities A on A.extid1 = P.paceid and A.extid2 = P.ID and A.completedDate is null and A.currentlocationid in (select locationid from tbllocations where workflowid = 4) and A.visible = 1 and A.extid4 = 1
        where DateOfService >= @StartDate and DateOfService <= @EndDate
        and P.Deleted = 0
        and PC.Void = 0
        and (@Status is null or (a.currentlocationID = @Status))
        and (@Program is null or (P.Program in (select program from #T1)))
        and (@Clinician is null or (P.ClinicianUserID = @Clinician))
        and (@LateEntryOnly = 0 or (P.LateEntry = @LateEntryOnly))
        and ((@Billable =0) or (@Billable = 1 and PC.Billable = 1) or (@Billable = 2 and PC.Billable = 0))

        Union All
        select distinct
        Isnull(U.LastName,'') + ', ' + IsNull(U.Firstname,'') as Clinician,
        convert(varchar(15),P.DateOfService,101) as DateOfService,
        P.PaceID,
        Dem.LastName + ', ' + Dem.FirstName as ClientName,
        P.ID as ProgressNoteID,
        PC.BillingCodeID,
        PC.ProgressNoteType,
        BC.Code, 
        PC.POS,
        BC.MOD1,
        BC.MOD2,
        Isnull(BC.Code,'') + ' ' + ISnull(PC.POS,'') + ' ' + ISNULL(BC.MOD1,'') + ' ' + ISNULL(BC.MOD2,'') as FullHCPC,
        PC.Units,
        PC.TimeIn,
        PC.TimeOut,
        DateDiff(mi,pc.TimeIn,pc.TimeOut) as Minutes,
        Case when Datediff(mi,PC.TimeIn,PC.TimeOut)/60 > 0 
        then Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut)/60) + 'h ' + Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' else Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' end as TimeDesc,
        I.BehavioralHealthCategory,
        case when p.DateOfService > '8/1/13' and PC.BillingCodeID in (3,4) and PC.DOCID is null then 'Log Missing' else convert(varchar(20),PC.DocID) end as TransportationLog,
        L3.Description as Program,
        P.LateEntry,
        case when PC.Billable = 0 then 'Non Billable' else '' end as NonBillable,
        (Convert(float,IsNull(R.RateAmount,0)) * case when PC.Units ='' then 0 else Convert(float,PC.Units) end) as 'Service Value',
        a.currentlocation as Status

        from tblCrisisProgressNotes P
        left join tblProgressNoteCodes PC on PC.ProgressNoteID = P.ID and PC.ProgressNoteType = 2
        left join tblLicensure L on L.ProviderID = P.ClinicianID and L.[Primary] = 1 and P.DateOfService >= L.StartDate and (L.EndDate is null or L.EndDate >= P.DateOfService)
        left join tblLookups L2 on L2.Code = L.LicenseTypeID and L2.CategoryID = 48
        left join tblLookups L3 on L3.Code = P.Program and L3.CategoryID = 104
        left join #tmpRates R on R.BillingCodeID = PC.BillingCodeID and R.POS = PC.POS and R.LicenseGroupID = L2.Type and R.Billable = PC.Billable and R.ProviderID = P.Site
             and R.StartDate <= p.DateOfService and R.EndDate >= p.DateOfService
        left join tblBillingCodes BC on BC.ID = PC.BillingCodeID
        left join tblDemographics Dem on Dem.PaceID = P.PaceID
        left join tblIntakes I on I.ID = P.IntakeID
        left join tblReferrals CR on CR.ID = I.ReferralID
        left join tblProviders PP on PP.ID = P.ClinicianID
        left join vwUsers U on U.ID = PP.UserID
        left join tblactivities A on A.extid1 = P.paceid and A.extid2 = P.ID and A.completedDate is null and A.currentlocationid in (select locationid from tbllocations where workflowid = 4) and A.visible = 1 and A.extid4 = 2
        where P.DateOfService >= @StartDate and P.DateOfService <= @EndDate
        and P.Deleted = 0
        and PC.Void = 0
        and (@Status is null or (a.currentlocationID = @Status))
        and (@Program is null or (P.Program in (select program from #T1)))
        and (@Clinician is null or (P.ClinicianUserID = @Clinician))
        and (@LateEntryOnly = 0 or (P.LateEntry = @LateEntryOnly))
        and ((@Billable =0) or (@Billable = 1 and PC.Billable = 1) or (@Billable = 2 and PC.Billable = 0))

        Union All
        select distinct
        Isnull(U.LastName,'') + ', ' + IsNull(U.Firstname,'') as Clinician,
        convert(varchar(15),p.DateOfService,101) as DateOfService,
        P.PaceID,
        Dem.LastName + ', ' + Dem.FirstName as ClientName,
        P.ID as ProgressNoteID, 
        PC.BillingCodeID,
        PC.ProgressNoteType,
        BC.Code, 
        PC.POS,
        BC.MOD1,
        BC.MOD2,
        Isnull(BC.Code,'') + ' ' + ISnull(PC.POS,'') + ' ' + ISNULL(BC.MOD1,'') + ' ' + ISNULL(BC.MOD2,'') as FullHCPC,
        PC.Units,
        PC.TimeIn,
        PC.TimeOut,
        DateDiff(mi,pc.TimeIn,pc.TimeOut) as Minutes,
        Case when Datediff(mi,PC.TimeIn,PC.TimeOut)/60 > 0 
        then Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut)/60) + 'h ' + Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' else Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' end as TimeDesc,
        I.BehavioralHealthCategory,
        case when p.DateOfService > '8/1/13' and PC.BillingCodeID in (3,4) and PC.DOCID is null then 'Log Missing' else convert(varchar(20),PC.DocID) end as TransportationLog,
        L3.Description as Program,
        P.LateEntry,
        case when PC.Billable = 0 then 'Non Billable' else '' end as NonBillable,
        (Convert(float,IsNull(R.RateAmount,0)) * Convert(float,PC.Units)) as 'Service Value',
        a.currentlocation as Status
        from tblPersonalProgressNotes P
        left join tblProgressNoteCodes PC on PC.ProgressNoteID = P.ID and PC.ProgressNoteType = 3
        left join tblLicensure L on L.ProviderID = P.ClinicianID and L.[Primary] = 1 and P.DateOfService >= L.StartDate and (L.EndDate is null or L.EndDate >= P.DateOfService)
        left join tblLookups L2 on L2.Code = L.LicenseTypeID and L2.CategoryID = 48
        left join tblLookups L3 on L3.Code = P.Program and L3.CategoryID = 104
        left join #tmpRates R on R.BillingCodeID = PC.BillingCodeID and R.POS = PC.POS and R.LicenseGroupID = L2.Type and R.Billable = PC.Billable and R.ProviderID = P.Site
             and R.StartDate <= p.DateOfService and R.EndDate >= p.DateOfService
        left join tblBillingCodes BC on BC.ID = PC.BillingCodeID
        left join tblDemographics Dem on Dem.PaceID = P.PaceID
        left join tblIntakes I on I.ID = P.IntakeID
        left join tblReferrals CR on CR.ID = I.ReferralID
        left join tblProviders PP on PP.ID = P.ClinicianID
        left join vwUsers U on U.ID = PP.UserID
        left join tblactivities A on A.extid1 = P.paceid and A.extid2 = P.ID and A.completedDate is null and A.currentlocationid in (select locationid from tbllocations where workflowid = 4) and A.visible = 1 and A.extid4 = 3
        where P.DateOfService >= @StartDate and P.DateOfService <= @EndDate
        and P.Deleted = 0
        and PC.Void = 0
        and (@Status is null or (a.currentlocationID = @Status))
        and (@Program is null or (P.Program in (select Program from #T1)))
        and (@Clinician is null or (P.ClinicianUserID = @Clinician))
        and (@LateEntryOnly = 0 or (P.LateEntry = @LateEntryOnly))
        and ((@Billable =0) or (@Billable = 1 and PC.Billable = 1) or (@Billable = 2 and PC.Billable = 0))
        order by Clinician, DateOfService,Code, POS, MOD1, MOD2 ,ClientName, TimeIn

        END
        Else
        BEGIN

        select distinct
        Isnull(U.LastName,'') + ', ' + IsNull(U.Firstname,'') as Clinician,
        convert(varchar(15),p.DateOfService,101) as DateOfService,
        P.PaceID,
        Dem.LastName + ', ' + Dem.FirstName as ClientName,
        P.ID as ProgressNoteID,
        PC.BillingCodeID,
        PC.ProgressNoteType,
        BC.Code, 
        PC.POS,
        BC.MOD1,
        BC.MOD2,
        Isnull(BC.Code,'') + ' ' + ISnull(PC.POS,'') + ' ' + ISNULL(BC.MOD1,'') + ' ' + ISNULL(BC.MOD2,'') as FullHCPC,
        PC.Units,
        PC.TimeIn,
        PC.TimeOut,
        DateDiff(mi,PC.TimeIn, PC.TimeOut) as Minutes,
        Case when Datediff(mi,PC.TimeIn,PC.TimeOut)/60 > 0 
        then Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut)/60) + 'h ' + Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' else Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' end as TimeDesc,
        I.BehavioralHealthCategory,
        case when p.DateOfService > '8/1/13' and PC.BillingCodeID in (3,4) and PC.DOCID is null then 'Log Missing' else convert(varchar(20),PC.DocID) end as TransportationLog,
        L3.Description as Program,
        P.LateEntry,
        a.currentlocation as Status
        from tblProgNotes P
        left join tblProgressNoteCodes PC on PC.ProgressNoteID = P.ID and PC.ProgressNoteType = 1
        left join tblLicensure L on L.ProviderID = P.ClinicianID and L.[Primary] = 1 and P.DateOfService >= L.StartDate and (L.EndDate is null or L.EndDate >= P.DateOfService)
        left join tblLookups L2 on L2.Code = L.LicenseTypeID and L2.CategoryID = 48
        left join tblLookups L3 on L3.Code = P.Program and L3.CategoryID = 104
        left join #tmpRates R on R.BillingCodeID = PC.BillingCodeID and R.POS = PC.POS and R.LicenseGroupID = L2.Type and R.Billable = PC.Billable and R.ProviderID = P.Site
             and R.StartDate <= p.DateOfService and R.EndDate >= p.DateOfService
        left join tblBillingCodes BC on BC.ID = PC.BillingCodeID
        left join tblDemographics Dem on Dem.PaceID = P.PaceID
        left join tblIntakes I on I.ID = P.IntakeID
        left join tblReferrals CR on CR.ID = I.ReferralID
        left join tblProviders PP on PP.ID = P.ClinicianID
        left join vwUsers U on U.ID = PP.UserID
        left join tblactivities A on A.extid1 = P.paceid and A.extid2 = P.ID and A.completedDate is null and A.currentlocationid in (select locationid from tbllocations where workflowid = 4) and A.visible = 1 and A.extid4 = 1
        where DateOfService >= @StartDate and DateOfService <= @EndDate
        and P.Deleted = 0
        and PC.Void = 0
        and (@Status is null or (a.currentlocationID = @Status))
        and (@Program is null or (P.Program in (select program from #T1)))
        and (@Clinician is null or (P.ClinicianUserID = @Clinician))
        and (@LateEntryOnly = 0 or (P.LateEntry = @LateEntryOnly))
        and ((@Billable =0) or (@Billable = 1 and PC.Billable = 1) or (@Billable = 2 and PC.Billable = 0))

        Union All
        select distinct
        Isnull(U.LastName,'') + ', ' + IsNull(U.Firstname,'') as Clinician,
        convert(varchar(15),P.DateOfService,101) as DateOfService,
        P.PaceID,
        Dem.LastName + ', ' + Dem.FirstName as ClientName,
        P.ID as ProgressNoteID,
        PC.BillingCodeID,
        PC.ProgressNoteType,
        BC.Code, 
        PC.POS,
        BC.MOD1,
        BC.MOD2,
        Isnull(BC.Code,'') + ' ' + ISnull(PC.POS,'') + ' ' + ISNULL(BC.MOD1,'') + ' ' + ISNULL(BC.MOD2,'') as FullHCPC,
        PC.Units,
        PC.TimeIn,
        PC.TimeOut,
        DateDiff(mi,pc.TimeIn,pc.TimeOut) as Minutes,
        Case when Datediff(mi,PC.TimeIn,PC.TimeOut)/60 > 0 
        then Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut)/60) + 'h ' + Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' else Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' end as TimeDesc,
        I.BehavioralHealthCategory,
        L3.Description as Program,
        case when p.DateOfService > '8/1/13' and PC.BillingCodeID in (3,4) and PC.DOCID is null then 'Log Missing' else convert(varchar(20),PC.DocID) end as TransportationLog,
        P.LateEntry,
        a.currentlocation as Status
        from tblCrisisProgressNotes P
        left join tblProgressNoteCodes PC on PC.ProgressNoteID = P.ID and PC.ProgressNoteType = 2
        left join tblLicensure L on L.ProviderID = P.ClinicianID and L.[Primary] = 1 and P.DateOfService >= L.StartDate and (L.EndDate is null or L.EndDate >= P.DateOfService)
        left join tblLookups L2 on L2.Code = L.LicenseTypeID and L2.CategoryID = 48
        left join tblLookups L3 on L3.Code = P.Program and L3.CategoryID = 104
        left join #tmpRates R on R.BillingCodeID = PC.BillingCodeID and R.POS = PC.POS and R.LicenseGroupID = L2.Type and R.Billable = PC.Billable and R.ProviderID = P.Site
             and R.StartDate <= p.DateOfService and R.EndDate >= p.DateOfService
        left join tblBillingCodes BC on BC.ID = PC.BillingCodeID
        left join tblDemographics Dem on Dem.PaceID = P.PaceID
        left join tblIntakes I on I.ID = P.IntakeID
        left join tblReferrals CR on CR.ID = I.ReferralID
        left join tblProviders PP on PP.ID = P.ClinicianID
        left join vwUsers U on U.ID = PP.UserID
        left join tblactivities A on A.extid1 = P.paceid and A.extid2 = P.ID and A.completedDate is null and A.currentlocationid in (select locationid from tbllocations where workflowid = 4) and A.visible = 1 and A.extid4 = 2
        where P.DateOfService >= @StartDate and P.DateOfService <= @EndDate
        and P.Deleted = 0
        and PC.Void = 0
        and (@Status is null or (a.currentlocationID = @Status))
        and (@Program is null or (P.Program in (select program from #T1)))
        and (@Clinician is null or (P.ClinicianUserID = @Clinician))
        and (@LateEntryOnly = 0 or (P.LateEntry = @LateEntryOnly))
        and ((@Billable = 0) or (@Billable = 1 and PC.Billable = 1) or (@Billable = 2 and PC.Billable = 0))

        Union All
        select distinct
        Isnull(U.LastName,'') + ', ' + IsNull(U.Firstname,'') as Clinician,
        convert(varchar(15),p.DateOfService,101) as DateOfService,
        P.PaceID,
        Dem.LastName + ', ' + Dem.FirstName as ClientName,
        P.ID as ProgressNoteID, 
        PC.BillingCodeID,
        PC.ProgressNoteType,
        BC.Code, 
        PC.POS,
        BC.MOD1,
        BC.MOD2,
        Isnull(BC.Code,'') + ' ' + ISnull(PC.POS,'') + ' ' + ISNULL(BC.MOD1,'') + ' ' + ISNULL(BC.MOD2,'') as FullHCPC,
        PC.Units,
        PC.TimeIn,
        PC.TimeOut,
        DateDiff(mi,pc.TimeIn,pc.TimeOut) as Minutes,
        Case when Datediff(mi,PC.TimeIn,PC.TimeOut)/60 > 0 
        then Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut)/60) + 'h ' + Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' else Convert(varchar(2),Datediff(mi,PC.TimeIn,PC.TimeOut) % 60) + 'm' end as TimeDesc,
        I.BehavioralHealthCategory,
        case when p.DateOfService > '8/1/13' and PC.BillingCodeID in (3,4) and PC.DOCID is null then 'Log Missing' else convert(varchar(20),PC.DocID) end as TransportationLog,
        L3.Description as Program,
        P.LateEntry,
        a.currentlocation as Status
        from tblPersonalProgressNotes P
        left join tblProgressNoteCodes PC on PC.ProgressNoteID = P.ID and PC.ProgressNoteType = 3
        left join tblLicensure L on L.ProviderID = P.ClinicianID and L.[Primary] = 1 and P.DateOfService >= L.StartDate and (L.EndDate is null or L.EndDate >= P.DateOfService)
        left join tblLookups L2 on L2.Code = L.LicenseTypeID and L2.CategoryID = 48
        left join tblLookups L3 on L3.Code = P.Program and L3.CategoryID = 104
        left join #tmpRates R on R.BillingCodeID = PC.BillingCodeID and R.POS = PC.POS and R.LicenseGroupID = L2.Type and R.Billable = PC.Billable and R.ProviderID = P.Site
             and R.StartDate <= p.DateOfService and R.EndDate >= p.DateOfService
        left join tblBillingCodes BC on BC.ID = PC.BillingCodeID
        left join tblDemographics Dem on Dem.PaceID = P.PaceID
        left join tblIntakes I on I.ID = P.IntakeID
        left join tblReferrals CR on CR.ID = I.ReferralID
        left join tblProviders PP on PP.ID = P.ClinicianID
        left join vwUsers U on U.ID = PP.UserID
        left join tblactivities A on A.extid1 = P.paceid and A.extid2 = P.ID and A.completedDate is null and A.currentlocationid in (select locationid from tbllocations where workflowid = 4) and A.visible = 1 and A.extid4 = 3
        where P.DateOfService >= @StartDate and P.DateOfService <= @EndDate
        and P.Deleted = 0
        and PC.Void = 0
        and (@Status is null or (a.currentlocationID = @Status))
        and (@Program is null or (P.Program in (select program from #T1)))
        and (@Clinician is null or (P.ClinicianUserID = @Clinician))
        and (@LateEntryOnly = 0 or (P.LateEntry = @LateEntryOnly))
        and ((@Billable = 0) or (@Billable = 1 and PC.Billable = 1) or (@Billable = 2 and PC.Billable = 0))
        order by Clinician, DateOfService,Code, POS, MOD1, MOD2 ,ClientName, TimeIn
        END

        drop table #tmpRates
        drop table #T1

将您的查询替换为以下内容:

    set  @SQLQuery = ' select distinct program from tblProgNotes where Program in (' + @Program + ')'

替换为“=”,然后进行检查。现在,此错误导致运行:System.Data.SqlClient.SqlException:附近的语法不正确。请提供您正在传递的输入@programset@SQLQuery='从Rms中选择不同的DeviceInId。Device其中DeviceInId位于'+CAST@Program正如VARCHAR10+一样,您也不需要创建查询来执行插入临时表字符串项=;如果RadCombox1.CheckedItems.Count>0{foreach RadCombox1.CheckedItems中的RadComboxItems+=item.Value+,;}items=items.Removeitems.Length-1;项目=项目+;