Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
How to store multiple values in a variable?For MS SQL, you can use list functions. STRING_SPLIT (Transact-SQL) and STRING_AGG (Transact-SQL) .
DECLARE @Role TABLE(Role VARCHAR(100))
INSERT INTO @Role SELECT TRIM( value ) FROM STRING_SPLIT( @RLR, ',' )
INSERT INTO @Role SELECT TRIM( value ) FROM STRING_SPLIT( @ROL, ',' )
WHERE TRIM( value ) NOT IN ( SELECT [Role] FROM @Role )
DELETE @Role WHERE (TRIM( [Role] ) = '')
SELECT @RLR = STRING_AGG ( [Role], ', ' ) FROM @Role
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question