Hey guys!!
I would like to share with you a really cool new feature that I noticed in Azure SQL Database, which was the inclusion of a new parameter in the STRING_SPLIT function and that has been requested since the function was created in SQL Server 2016, which is the inclusion of the number of positions in the return of text breaks.
This function is so new that at the time of this publication, this new parameter is only available in the English version of the documentation:

For those who don't remember, this function is used like this:

The problem is that the function did not return the position number, so it was difficult to get the first element or the Nth element from the return. As a result, I ended up using other alternatives, as I already demonstrated in the article How to break a string into a substring table using a delimiter in SQL Server and that works on any version of SQL Server.
However, to my surprise, today I discovered that Azure SQL Database has already implemented a change to the STRING_SPLIT function and is now allowing it to return the position number:

And now, I can choose the elements I want:

If we try to reproduce the same thing in SQL Server 2019, we come across this error message:

So I imagine that an update should be released soon to include this improvement for the On-Premises versions.
- SQL Server – charindexada: A different function for breaking delimited strings (split)
- SQL Server – Breaking strings into sub-strings using split string
- SQL Server – Table-valued function to break a string into lines up to N characters long
- How to break a string into a substring table using a delimiter in SQL Server
- SQL Server – Using STRING_SPLIT to transform single-row strings into columns
So that's it, folks!
Short, quick and informative post.
A big hug and see you next time!
Comentários (0)
Carregando comentários…