I have a table and values like this
CREATE TABLE BarcodeTABLE
(
ID INT IDENTITY,
BARCODE_VALUE nvarchar(max),
GTIN2 nvarchar(MAX),
HIBC NVARCHAR(max),
UPC nvarchar(max),
Others2 nvarchar(max)
)
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('012,56', '012', '', '', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('05,C50,25', 'C50', '25', '', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('1,2,3', '1', '', '', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('5,6,7', '', '', '7', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('8,9,10', '', '9', '', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('100,200,300', '100', '', '', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('A12,12', '', 'A12', '', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('B25,10', '', 'B25', '', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('H65,26,0', 'H65', '', '', '')
INSERT INTO BarcodeTABLE(BARCODE_VALUE, GTIN2, HIBC, UPC, OTHERS2)
VALUES('H75,22,25', 'H75', '', '', '')
I need to get the output like as shown in the image, i.e the values which are not there in few columns should be there in the separate column as shown in the figure, give me the easiest way to achieve this: