Topic: where in
For example there is table A of two fields:
id int (identifier)
fio nvarchar (50) (surname)
In other table in the field ids nvarchar (MAX) are stored the list id through a separator a comma, for example ' 1,5,18'
The task: to make function returning line with surnames through a separator-comma
Problem: in functions it is impossible to use temporary tables, wanted a line ' 1,5,18 ' in the temporary table and
select @s = s + RTRIM (A.FIO) + ', ' from ##temp inner join A on ##temp.id=A.id
It would turn out as a result for example ' Ivanov, Petrov, Sidorov,'
Wanted to cause from function EXECUTE sp_executesql - too it is impossible...
Prompt, can eat a simple variant? That that of type select * from A where id in *** IDs ***