About 5,150,000 results
Open links in new tab
  1. T-SQL split string based on delimiter - Stack Overflow

    Feb 14, 2014 · The general idea is to split out all of the characters in the string, determine the position of the delimiters, then obtain substrings relative to the delimiters. Here is a sample: -- Sample data DECLARE @testTable TABLE ( TestString VARCHAR(50) ) INSERT INTO @testTable VALUES ('Teststring,1,2,3') ,('Test') DECLARE @delimiter VARCHAR(1 ...

  2. sql - How do I split a delimited string so I can access individual ...

    Nov 2, 2015 · You may find the solution in SQL User Defined Function to Parse a Delimited String helpful (from The Code Project). You can use this simple logic: IF PATINDEX('%|%', @products) > 0. BEGIN. SET @individual = SUBSTRING(@products, 0, PATINDEX('%|%', @products)) SELECT @individual. SET @products = SUBSTRING(@products, LEN(@individual + '|') + 1,

  3. How to Split a Delimited String to Access Individual Items in SQL?

    Mar 26, 2024 · SQL Server introduced the STRING_SPLIT function to directly split delimited strings into a table of values. It takes the input string and delimiter as parameters, returning a table with individual items.

  4. sql - Extract characters to the right of a delimited value in a SELECT ...

    Sep 25, 2013 · If using SQL Server: SELECT column1 , RIGHT(column2,CHARINDEX('-',REVERSE(column2))-1) as extracted , column3 FROM myTable You can add a CASE statement or use NULLIF() in case the hyphen isn't always present:

  5. 4 Ways to Split String by Delimiter in SQL - TechCult

    Jan 31, 2023 · Method 2: SQL Server Split String. You can use the STRING_SPLIT() function in the SQL server to split a delimited string. Syntax: STRING_SPLIT (string , delimiter ) Example: SELECT VALUE FROM STRING_SPLIT('m,n,o,p,q,r', ','); Output: VALUE-----m n o p q r Method 3: PostgreSQL Split String

  6. Split Delimited String into Columns in SQL Server

    Dec 30, 2024 · Learn how to parse or split SQL Server strings from one column into multiple columns using the parsename and other T-SQL functions.

  7. STRING_SPLIT (Transact-SQL) - SQL Server | Microsoft Learn

    Oct 30, 2023 · STRING_SPLIT inputs a string that has delimited substrings and inputs one character to use as the delimiter or separator. Optionally, the function supports a third argument with a value of 0 or 1 that disables or enables, respectively, the ordinal output column.

  8. 4 ways to convert delimited string data into individual rows in SQL ...

    Jul 5, 2021 · Lets go through this step-by-step by first looking at why we are using LEFT() and STUFF(). LEFT() will basically extract the individual values from CSV strings that we'll then use to generate the rows. So in the anchor member, it will extract 18 out of 18,20,45,68 and Jon out of Jon,Sansa,Arya,Robb,Bran,Rickon. STUFF() will kind of do the opposite.

  9. sql server - Parse a string to find data between delimiters, …

    Jan 27, 2017 · Easy way is to create this split function and use SUBSTRING and CHARINDEX over the data returned by the function. @string NVARCHAR(MAX), . @delimiter CHAR(1) . DECLARE @start INT, @end INT . SELECT @start = 1, @end = CHARINDEX(@delimiter, @string) . WHILE @start < LEN(@string) + 1 BEGIN . IF @end = 0 . …

  10. Parse delimited values in SQL Server with STRING_SPLIT

    Sep 24, 2020 · Have you ever needed to get values from a delimited string in SQL Server? This post will look at how to do this with the SQL Server function, STRING_SPLIT. Before the inclusion of STRING_SPLIT, there were a couple of options to achieve this. Define a string splitting function yourself, or use recursive CTEs.

  11. Some results have been removed
Refresh