help me plz.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghousal
    New Member
    • Nov 2007
    • 4

    help me plz.

    i have a query i.e
    "select ename from emp"
    am getting result as
    ename
    aaa
    bbb
    ccc
    ddd
    ok
    means i want to get these values 1 beside 1 like
    aaa bbb ccc ddd etc
    plz help me out
  • CyberSoftHari
    Recognized Expert Contributor
    • Sep 2007
    • 488

    #2
    Explain your problem in detail.

    Comment

    • jamesd0142
      Contributor
      • Sep 2007
      • 471

      #3
      Originally posted by CyberSoftHari
      Explain your problem in detail.
      I think this is explained well enough...

      Basically all retrieved values in the same row rather than a row for each value

      Comment

      • CyberSoftHari
        Recognized Expert Contributor
        • Sep 2007
        • 488

        #4
        Did he mean cross tab query?

        You have to use storeprocedure.
        Last edited by CyberSoftHari; Dec 7 '07, 03:26 AM. Reason: You have to

        Comment

        • Jim Doherty
          Recognized Expert Contributor
          • Aug 2007
          • 897

          #5
          Originally posted by ghousal
          i have a query i.e
          "select ename from emp"
          am getting result as
          ename
          aaa
          bbb
          ccc
          ddd
          ok
          means i want to get these values 1 beside 1 like
          aaa bbb ccc ddd etc
          plz help me out

          Here is a stored procedure that will return you your single row separating the values with one space (you can amend that obviously to suit you)

          Code:
           
          CREATE PROCEDURE dbo.usp_MySP
          AS
          DECLARE @a varchar(8000)
          SELECT @a=COALESCE(@a, '') + ename + space(1) FROM (SELECT distinct (ename) from emp) as a
          SELECT rtrim(ltrim(@a)) AS [MyValues]
          GO
          Regards

          Jim :)

          Comment

          Working...