Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. display a column horizandally

display a column horizandally

Scheduled Pinned Locked Moved Database
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jegastar
    wrote on last edited by
    #1

    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

    N S 2 Replies Last reply
    0
    • J 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

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      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.


      My Website | Ask smart questions

      1 Reply Last reply
      0
      • J 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

        S Offline
        S Offline
        Senu Gandhi
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups