You must Sign In to post a response.
  • Category: SQL Server

    I want to dsiplay the Details from table to single line string using store procedure

    In table records as follows


    SchDate Course Session Subject Faculty

    Aug25 B Tech 1 1 A CMK
    Aug25 B Tech 2 2 B CMK
    Aug26 B SC 1 3 C CMK
    Aug26 B SC 2 4 D CMK
    Aug27 GP 1 5 E CMK
    Aug27 GP 2 6 F CMK
    Aug28 DME 1 3 G CMK
    Aug28 DME 2 4 H CMK


    From the above table i want to display table records as follows using store procedure.


    Dear CMK, Aug25(B Tech1 -A/1,B Tech 2 -B/2) Aug 26(B SC 1 -C/3,B SC 2 -D/4) Aug27(GP 1 -E/5,GP 2 -F/6) Aug 28(DME 1 -G/3,DME 1-H/4) - By Admin

    For that how can i do using store procedure

    Regards,
    Narasiman P.
  • #749955
    Hi

    You can get comma separated values in SQL Server using COALESCE function

    DECLARE @List varchar(2000)

    SELECT @List = COALESCE(@List + ',', '') + [Column Name]
    FROM [Table Name]

    SELECT @List

  • #750042
    Hai Narasiman,
    It will be quite complicated to achieve the desired results in the database side as per your description.
    Rather than try to get them in your front end which will be easy to display if you want to.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


  • Sign In to post your comments