For instance I have a string parameter @p_colors
with a value like:
'yellow','blue','red'
which is passed into a stored procedure. And when I try to select it like this:
EXECUTE(CONCAT('SELECT ', @p_colors));
The result is the values are selected by columns.
No column name | No column name | No column name
------------------------------------------------
Yellow | Blue | Red
How will I do it if I want to display them by row like this:
No column name |
----------------
Yellow |
----------------
Blue |
----------------
Red |
----------------
using only the string formatted parameter. Is there any way in SQL to make this?
EDIT:
The actual result will be inserted into a temp table so the actual code is :
EXECUTE('INSERT INTO #colors(color) SELECT ', @p_colors);