我正在尝试将此查询从mysQL转换为SQL Server。
SELECT TOP 50 m.*,
(SELECT GROUP_CONCAT(lookup_id) as ids FROM data_lookups_ref WHERE ref_id = m.member_id and lu_type = 'prof_accr_status') as prof_accr_status_ids
FROM members m;
基于其他信息在那里,我已将其转换为此
SELECT TOP 50 m.*,
id_list = STUFF((
SELECT ',' + lu.lookup_id
FROM data_lookups_ref lu
WHERE lu.ref_id = m.member_id
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '')
FROM members m;
但是我收到以下错误。
ERROR: SELECT failed because the following SET options have incorrect
settings: 'ARITHABORT'. Verify that SET options are
correct for use with indexed views and/or indexes on computed
columns and/or filtered indexes and/or query notifications
and/or XML data type methods and/or spatial index operations.
Error
Code: 1934
任何有关错误的建议都将受到赞赏。
答案 0 :(得分:1)
请你试试这个:
SELECT TOP 50 m.*,
STUFF((
SELECT TOP 50 ',' + convert(varchar(10), lu.lookup_id)
FROM data_lookups_ref lu
WHERE lu.ref_id = m.member_id
FOR XML PATH('')),1,1,'') AS ids
FROM members m