Humble novice
This bit is fine (a fiddle is available [here](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=72a86755a4ae6771ebeeea14310f7db1)).
```
SELECT
value
FROM
STRING_SPLIT('red,green,,blue', ',');
```
But I then did this
```
CREATE TABLE x (y VARCHAR (34));
```
and
```
INSERT INTO x VALUES ('sfsd, sadfs, sfds'), ('wwer, rtryr, 65555');
```
and I've been trying to apply STRING_SPLIT to the field y - I've tried stuff like
```
SELECT STRING_SPLIT (y, ',') FROM x;
```
and I get this
```
Msg 195 Level 15 State 10 Line 1
'STRING_SPLIT' is not a recognized built-in function name.
```
I've tried various things and no luck - could somebody show me how to use this function?
The result I want it:
```
field_name
sfsd
sadfs
sfds
wwer
rtryr
65555
```
Is this what STRING_SPLIT is for? Have I completely misunderstood this?
Top Answer
Jack Douglas
`STRING_SPLIT` [is a table-valued function](https://docs.microsoft.com/en-us/sql/t-sql/functions/string-split-transact-sql?view=sql-server-ver15):
> A table-valued function that splits a string into rows of substrings, based on a specified separator character.
It need to appear in the `FROM` clause because the return type is a single-column table:
> Returns a single-column table whose rows are the substrings. The name of the column is value.
If you want to `STRING_SPLIT` on several strings, you probably need [`CROSS APPLY`](https://docs.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql?view=sql-server-ver15#using-apply):
> …the *right_table_source* can use a table-valued function that takes a column from the *left_table_source* as one of the arguments of the function.
<>https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=c4c76d155de9e127cec5782b3dd56215&hide=3