Questions tagged [string-splitting]
Use for questions about spitting strings using a specified delimiter.
42 questions
5
votes
2
answers
204
views
STRING_SPLIT - issue with NCHAR(769) and SQL_Latin1_General_CP1_CI_AS
In database
on SQL Server 2022 Standard Edition (CU19)
with default collation SQL_Latin1_General_CP1_CI_AS
I am splitting CHAR(31) separated values using STRING_SPLIT. I have an issue when the ...
25
votes
1
answer
2k
views
STRING_SPLIT with order not working on SQL Server 2022
I need to use STRING_SPLIT with enabled ordering:
We have upgraded all of our servers to SQL Server 2022 and change the compatibility level to 160, but the following code is not working:
SELECT * ...
3
votes
1
answer
154
views
Temp tables streamline query
I am trying to get to the Customer table from data in the SiteConfiguration table.
I am getting the data and setting it to @AdditionalVoteViewers, which would be a string of emails address. I then ...
3
votes
2
answers
601
views
How to delay convert() evaluation until after join
The following query converts a single string of packed CSV that represents 13k rows by 2 columns. Column A is a bigint. Column B is a smallint.
declare
@dataCsv nvarchar(max) = '29653,36,19603,...
0
votes
2
answers
2k
views
Converting multiple comma-separated columns into rows
I have an SQL Server database table that holds comma separated values in many columns. For example:
id
Column B
column c
1
a,b,c,
1,2,3,
2
d, ,f,
4,5,6,
3
g,h,i,j,
7, ,9,8,
I want to split all the ...
-3
votes
1
answer
893
views
I want to split the text in the row into separate columns
I have this column and rows
I want to split the text in the row into separate columns like this.
0
votes
3
answers
2k
views
Extract a substring where the delimiter might appear more than once
I have a column of strings with this pattern <email> - <id>. Email is always the first string.
I would like to extract only the email address but the problem here is that an email address ...
-2
votes
1
answer
1k
views
split a row value according to a specific column
I have total value in table A and need to get row value in table B until reached value in table A.
Table A
ID
Available
1
99
2
0
Table B
ID
Rack
RequiredQty
1
A
60
1
B
102
1
C
8
2
A
10
Expected ...
-4
votes
1
answer
257
views
Select INTs from start of string separated by a character (pipe). Update other columns using these INTs
In the above screen shot, the Description column has many special characters. We want before | number update in T1 column and | after number in T2 column. Please suggest the proper syntax.
If there ...
5
votes
1
answer
234
views
Match .csv values as INTs. If one value from a group in the .csv matches one in another group, then merge strings
Here we have two sets of numbers. The problem is that I can't figure out how to get from the input to the output of numbers (DDL and DML below and also in the fiddle here).
current_data
1,2,3
1,4
1,5,...
7
votes
1
answer
20k
views
Split a comma-separated record into its own rows
I have the following table, named stores:
store_id INT
emails VARCHAR
That contains values:
store_id
emails
1
[email protected],[email protected]
2
[email protected],[email protected]
4
admin@...
0
votes
2
answers
319
views
Transform a varchar field with #-delimiters into multiple rows
I am working with a database where some data (integer values representing selected options of a dropdown menue) is saved as a string (varchar) inside only one table column. In products_table (let's ...
1
vote
2
answers
4k
views
Splitting a column on underscores [duplicate]
What SQL syntax would split this column into three new columns (split would be on the underscore)?
There are other columns in the table, but I would like to split these into three (underscore based).
0
votes
1
answer
138
views
How to split field and run sub query using it?
Given two tables T1 and T2 below, is there a way in MySQL 5.7.x to get such a list field from T1, so that none of its entries are present in T2?
T1.list is a regular VARCHAR, containing T2.vals ...
3
votes
3
answers
6k
views
How did you split strings before string_split()
I have some strings I need to split on a SQL Server 2014 instance.
I would normally do it something like this:
declare @bk nvarchar(1000)
set @bk = 'SIS5.0~person_id~696969'
select value from ...