This is a simple question and I can\'t seem to think of a solution.
I have this defined in my stored procedure:
@communityDesc varchar(255) = NULL
You can simply split this csv using XML and use this to filter in your query. No need to use a User defined function or @Table_Valiable or #Temp_Table here.
DECLARE @xml as xml,@communityDesc varchar(255) = 'aaa,bbb,ccc'
SET @xml = cast((''+replace(@communityDesc,',' ,' ')+' ') as xml)
SELECT * FROM TABLE1
WHERE AREA IN (
SELECT N.value('.', 'varchar(10)') as value FROM @xml.nodes('X') as T(N)
)
If you required this split values in further process, then you can Insert this to a #table_Variable or #Temp_Table and use them.