Msg 512, Level 16, State 1, Line 3
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
我有 Id 值作为 varchar,如下所示。
'1,2,3,4,5,6,7,8,9'
我在 ID 列表上方列出,但是如果我有超过 1 行,我会得到上述异常。
DECLARE @List varchar(255)= (SELECT FIRSAT_PERSONELLER_ID FROM FIRSATLAR)
DECLARE @X XML
SELECT @X = '<myxml><nodes><n>' +
REPLACE(@List,',','</n></nodes><nodes><n>') +
'</n></nodes></myxml>'
SELECT LTRIM(C.value('n[1]','VARCHAR(50)')) AS item1
FROM @X.nodes('/myxml/nodes') Cols (C)