Thursday, 16 August 2018

How to concatenate text from multiple rows into a single text string in SQL server?

 

SELECT DISTINCT SBM.Barcode_Autogen_No,
    SUBSTRING(
        (
            SELECT Barcode_No_Char  AS [text()]
            FROM FP_Stock_Barcode_Details SBD
            WHERE SBM.Barcode_Autogen_No = SBD.Barcode_Autogen_No
            ORDER BY SBM.Barcode_Autogen_No
            FOR XML PATH ('')
        ), 2, 1000) [Students]
FROM FP_Stock_Barcode_Details SBM

No comments:

Post a Comment

Top Agile Interview Questions & Answers

Top Agile Interview Questions & Answers 1. What is Agile Testing? The first question of agile interview question tests your k...