且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server,IN子句中的变量

更新时间:2023-11-14 20:18:46

您将不得不将这些值插入到临时表中.

You will have to insert the values into a temp table.

类似

DECLARE @TempTable TABLE(
        assessmentId VARCHAR(50)
)
INSERT INTO @TempTable 
VALUES 
('02ea2b81-07f0-4660-bca1-81563f65bf65'),
('07728975-cb1d-484c-8894-14f5b793cbef'),
('1071ee4f-a214-443f-8694-0b3e9d2dc77e'),
('120d2881-b04f-4707-a925-e4d941f03201'),
('23af54a7-6666-4747-a74a-c2101cda59b0'),
('260d2ce5-f4f0-4a0b-aa0b-3e1d2b5fcfeb'),
('2710a913-13e7-4300-91f1-2646e2f8449e'),
('2cebc482-4917-4aa3-973b-2481619a78e7')

SELECT  *
FROM    table 
where   AssessmentId IN (SELECT assessmentId FROM @TempTable)