- SQL Server - Breaking strings into sub-strings using a separator (Split string)
- SQL Server - Table-valued function to break a string into lines up to N characters long
- How to wrap a string in a substring table using a delimiter in SQL Server
- SQL Server - Charindex: A Different Function to Break Split Strings
- SQL Server - Using STRING_SPLIT to transform strings from a row into columns
Hello people,
Good afternoon!
In this post I will demonstrate a very nice table-valued function that lets you break a string in a substring table using a delimiter in SQL Server. What does that mean? Well, this makes you have a string and the function will turn that string into a table using a separator. In this table, each record will be a part of the string in the i + 1 index and you can easily work with these substrings.
Interested in learning more about split?
- Breaking strings into substrings using separator (Split string)
- Charindex: A different function to break split strings
- Table-valued function to break a string into lines up to N characters long
Function Usage Examples
How to implement this in your SQL Server database
This is the cool part: Get to work!
View source
Creating the function with the CLR
Another alternative to using this feature is through SQLCLR, a feature that allows you to create .NET code within the database and generally performs much better than Transact-SQL. If you do not know the CLR, learn more by accessing the post. Introduction to SQL Common Language Runtime (CLR) in SQL Server.
View C # Function (CLR) Source CodeSimple and practical, right?
Hugs!
sql server tsql query table function split explode text string substring break word function using delimiter delimiter
sql server tsql query table function split explode text string substring break word function using delimiter delimiter
Error executing the penultimate script:
Msg 7738, Level 16, State 2, Line 1
Cannot enable compression for object 'xyz'. Only SQL Server Enterprise Edition supports compression.