Home > database >  SQL server field separation
SQL server field separation

Time:11-18

SQL server database name field value is zhang SAN, li si, fifty... Now want them according to the comma split into different columns, how to deal with

CodePudding user response:

How many columns are dynamic? Each column dynamic a name?

CodePudding user response:

Please give the sample data, and expected results,

CodePudding user response:

Using STRING_SPLIT function,
-
SELECT the VALUE
The FROM uname CROSS the APPLY STRING_SPLIT ([name], ', ')

CodePudding user response:

refer to the second floor selling fruit net reply:
please give sample data, and the expected results,


As shown in figure, database with key1, key2 and key3, key4, four fields, key4 comma-delimited, split three fields before and after the content shall be displayed

CodePudding user response:

There will be a
Zhang Gan, li si, Cathy, what zhao six, seven

The data of more than three?

CodePudding user response:

February 16 references 5 floor response:
there will be a
Zhang Gan, li si, Cathy, what zhao six, seven

The data of more than three?

Yes, there are more than three data, specific quantity not sure

CodePudding user response:

Using string_split is the most convenient,
  • Related