Reputation: 5488
I have data like:
I would like to use OPENJSON
to make these ids into a single list:
1001
1002
1003
5
6
And also to remove any duplicates if possible. What is the correct way to achieve this?
Upvotes: 0
Views: 194
Reputation: 81930
You can use OPENJSON
in concert with a CROSS APPLY
Example
Declare @YourTable Table ([Users] varchar(50))
Insert Into @YourTable Values
('[1001,1002,1003]')
,('[5]')
,('[6]')
Select Distinct B.Value
From @YourTable A
Cross Apply ( Select * from OpenJSON([Users]) ) B
Returns
Value
1001
1002
1003
5
6
Upvotes: 1