This question already has answers here:
Turning a Comma Separated string into individual rows
(16 answers)
Closed 2 years ago.
NOIDEHOB_NOIDE1_4321-123
i want to create a querie that extract the following values from the example above:
NOIDEHOB
NOIDE1
4321-123
I need to base the query on the sign _. The values NOIDEHOB, NOIDE1 and 4321-123 are dynamic and the length will vary. There will never be any other _ sign in the string.
Any suggestions?
You can use string_split():
select s.value
from string_split('NOIDEHOB_NOIDE1_4321-123', '_') s
Related
This question already has answers here:
How to get the 1st value before delimiter in sql server
(4 answers)
How to split string with delimiter and get the first value
(1 answer)
Split string on only first occurance of character/delimiter
(4 answers)
Split the string. get first value of split SQL Server 2005
(1 answer)
Closed 10 months ago.
I have value like
b10F|b3432R|b2134D
I need to get only the first value before the pipe:
b10F
How can I do that?
use mysql query with SUBSTRING_INDEX
SELECT SUBSTRING_INDEX("b10F|b3432R|b2134D", "|", 1)
Maybe use this query which uses CHARINDEX function to find the location of first pipe character and then uses LEFT to get data till that position -1
SELECT
LEFT(
'b10F|b3432R|b2134D',
CHARINDEX('|', 'b10F|b3432R|b2134D' ) -1
)AS Output;
This question already has answers here:
Turning a Comma Separated string into individual rows
(16 answers)
Closed 6 years ago.
I have a table that has three columns
I want my result set to be like
You need to split the strings. Split strings the right way – or the next best way
If you are on Sql Server 2016 you can use the built in String_Split(): Splitting Strings: SQL Server 2016 To The Rescue!
This question already has answers here:
removing characters from field in MS Access database table
(4 answers)
Closed 8 years ago.
I have table with data like
samcol
60.78686
46.0000
45.43240
56.3453450
And i'm trying to remove '.' before decimal places. And table should looks like
samcol
6078686
460000
4543240
563453450
Use Replace String function to replace all the . with empty string
Select Replace(samcol,'.','') from yourtable
This question already has answers here:
How to split string using delimiter char using T-SQL?
(4 answers)
How to split a comma-separated value to columns
(38 answers)
Split values over multiple rows [duplicate]
(2 answers)
Closed 9 years ago.
I have this piece of text that is stored in our MS-SQL database (ignore the quotes and no, I can't redesign how this work specifically):
"TEST|00000298398293|EQ5|Patient"
Now, when I do a simple select, I get that result being returned. What I'd like to do is split that string based on the "|" character and return the individual strings associated with this string, so that I could have "TEST", "0000298398293", "EQ5" and "Patient" in different fields. How can I do this? In PHP, you can use the explode method, is there something like that in MS-SQL?
It's surely not the most elegant solution but i've used in in the past:
DECLARE #Sql varchar(50) = 'TEST|00000298398293|EQ5|Patient'
SELECT
PARSENAME(REPLACE(#sql,'|','.'),4),
PARSENAME(REPLACE(#sql,'|','.'),3),
PARSENAME(REPLACE(#sql,'|','.'),2),
PARSENAME(REPLACE(#sql,'|','.'),1)
Notice : This only works if you have 3 pipes, eventually consider to redesign your database in the future!
This question already has answers here:
How to get rightmost 10 places of a string in oracle
(5 answers)
Closed 8 years ago.
I have a table containing the following fields:
version
id
set_value
marker
I want to write a SELECT statement to query them. However, the values in the column marker are not easily readable. I would like to present a substring of that column. My question is how do I do this?
You can use this:
SELECT version,
id,
set_value,
SUBSTR(marker, 1, 10) AS marker
FROM ...
to select just the first ten characters of marker, and still have the resulting column be named "marker".
(See http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions169.htm.)
You can use the substr function.