Displaying records in new line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hsegoy1979
    New Member
    • Jun 2008
    • 30

    Displaying records in new line

    dear all
    iam new to sql server. I have a query. I want to display records in a new line.
    Iam using char(13) but it won't work.

    The table record contains only one field Name


    select * from record


    DECLARE @x varchar(8000)
    SELECT @x =COALESCE(@x+' ',+char(13))+IS NULL(Name,'')+c har(13) FROM record
    SELECT @x

    after executing above query result should come like
    abc
    xyz
    adz

    but it comes like abc xyz adz

    any help
    yogesh
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Where are you running this and why do you need to place it on the second line?

    -- CK

    Comment

    • hsegoy1979
      New Member
      • Jun 2008
      • 30

      #3
      Originally posted by ck9663
      Where are you running this and why do you need to place it on the second line?

      -- CK
      i need in my project.

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        You might want to consider just doing it on front-end side.

        -- CK

        Comment

        • hsegoy1979
          New Member
          • Jun 2008
          • 30

          #5
          Originally posted by ck9663
          You might want to consider just doing it on front-end side.

          -- CK
          Yes onfrontend side.Any help

          Regards
          Yogesh

          Comment

          • ck9663
            Recognized Expert Specialist
            • Jun 2007
            • 2878

            #6
            That would depend on your front-end tool.

            -- CK

            Comment

            • hsegoy1979
              New Member
              • Jun 2008
              • 30

              #7
              Originally posted by ck9663
              That would depend on your front-end tool.

              -- CK
              Front end tool is asp.net2005

              Comment

              • Delerna
                Recognized Expert Top Contributor
                • Jan 2008
                • 1134

                #8
                char(13) is a carriage return
                char(10) is a line feed

                you need to use both to goto a new line ( char(10) ) and position the cursor at the beginning of the new line( char(13) )

                that is why when you open text documents in notepad you sometimes get one line of text with 2 consecutive squares interspersed among the text
                1 square is char(10) and the 2nd is char(13)


                so
                [code=sql]
                SELECT @x =COALESCE(@x+' ',+char(13)+cha r(10))+ISNULL(N ame,'')+char(13 )+char(10) FROM record

                [/code]
                should work for you

                Comment

                • hsegoy1979
                  New Member
                  • Jun 2008
                  • 30

                  #9
                  Thankx a lot
                  But Iam running above query in sql server. It doesnot display records in next line

                  Regards
                  Yogesh

                  Comment

                  • deepuv04
                    Recognized Expert New Member
                    • Nov 2007
                    • 227

                    #10
                    Originally posted by hsegoy1979
                    Thankx a lot
                    But Iam running above query in sql server. It doesnot display records in next line

                    Regards
                    Yogesh
                    If you are getting results in Gridview mode it appears like in the same line, if you set your setting to view results to text you will get the desired output. it is in sql server.

                    check how it is appearing if you bind the results to frond-end controls.

                    Thanks

                    Comment

                    • hsegoy1979
                      New Member
                      • Jun 2008
                      • 30

                      #11
                      Thankx a lot
                      It is working.
                      :-)

                      Regards
                      Yogesh

                      Comment

                      Working...