Home > database >  For help, using SQL in what function can A table respectively into B table
For help, using SQL in what function can A table respectively into B table

Time:01-07

Turn to for help

How will the appearance of the table into A table B


CodePudding user response:

If you note the number of most is four, with the following a try, if number is greater than 4 and not fixed, it so dynamic,

 
The CREATE TABLE # T
(the NAME VARCHAR (10),
REMARK VARCHAR (20))

INSERT INTO # T
SELECT 'NAME1', 'A, B, C, D' UNION ALL
SELECT 'NAME2', 'A, C' UNION ALL
SELECT 'NAME3', 'A, B, D' UNION ALL
SELECT 'NAME4', 'C'


SELECT the NAME, PARSENAME (REPLACE (REMARK, ', ', '. '), 1) AS RM1,
PARSENAME (REPLACE (REMARK, ', ', '. '), 2) the AS RM2,
PARSENAME (REPLACE (REMARK, ', ', '. '), 3) AS RM3,
PARSENAME (REPLACE (REMARK, ', ', '. '), 4) AS RM4
The FROM # T
  • Related