display a column horizandally
-
Hi friends, I have a table like this Id City -- ---- 1 Chennai 2 Vilupuram 3 Trichy 4 Madurai But i want Output like this Chennai Vilupuram Trichy Madurai Simply i want to display a column horizandally in a row. Is it possible? Help me. Thanks --Jegastar
-
Hi friends, I have a table like this Id City -- ---- 1 Chennai 2 Vilupuram 3 Trichy 4 Madurai But i want Output like this Chennai Vilupuram Trichy Madurai Simply i want to display a column horizandally in a row. Is it possible? Help me. Thanks --Jegastar
jegastar wrote:
Simply i want to display a column horizandally in a row. Is it possible? Help me.
Use cursor and iterate through each row. Assign value to a variable and select the variable at the end.
-
Hi friends, I have a table like this Id City -- ---- 1 Chennai 2 Vilupuram 3 Trichy 4 Madurai But i want Output like this Chennai Vilupuram Trichy Madurai Simply i want to display a column horizandally in a row. Is it possible? Help me. Thanks --Jegastar
Hi, Try this DECLARE @str varchar(50) When using space as the delimiter --------------------------------- select @str = coalesce(@str+' ','')+Msg from Table1 SELECT @str Result: Chennai Vilupuram Trichy Madurai When using comma as the delimiter --------------------------------- Result: Chennai,Vilupuram,Trichy,Madurai Senthil