Select multiple values as a CSV

select STRING_AGG(FeatureId, ', ') from features where available = 1 -- produces 1,2,3,4,5

CSV as parameter in IN clause query

declare @csv nvarchar(max) = '1,2,3,4,5'
select * from table where id in (select trim(value) from string_split(@csv, ','))
Last updated: 6/22/2022 9:36:33 AM

Latest Updates

© 0 - 2025 - Mike Brind.
All rights reserved.
Contact me at Mike dot Brind at Outlook.com