Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Posts
    29

    Unanswered: Selecting Values in a Column as a Single Variable

    Hi,

    I have a table which has three Columns Col A, Col B, COl C. I want to select values in Column Col A into a Single Variable variable Val with a delimiter of my choice. I want to do this with opening a Cursor the reason being in the stored procedure where I want this query inserted as I already have two cursors open and I don't want a third cursor in the procedure.

    PLease help me.

    Regards
    Dinesh

  2. #2
    Join Date
    Jan 2002
    Posts
    12
    U can try this

    DECLARE @EMPLOYEELIST VARCHAR(100)

    SELECT @EMPLOYEELIST = COALESCE(@EMPLOYEELIST + ',', '') + CAST(ColumnName AS VARCHAR) FROM TableName

    SELECT @EMPLOYEELIST

    The delimiter specified here is comma.
    If you want some other delimiter , you can change it .
    NivasKhan

  3. #3
    Join Date
    May 2002
    Posts
    29
    Nivas,

    Thanks a lot yaar.

    Regards
    Dinesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •