Search results
15 kwi 2014 · declare @temp varchar(40) set @temp = 'BB10-1_X-4759-566549' select @temp, REVERSE(@temp) select REVERSE(substring(REVERSE(@temp),0,CHARINDEX('-',REVERSE(@temp),0))) Give this a shot. It answers your first question of extracting from after the last - of the string.
22 mar 2022 · Example 1: Substring From a String Literal. The SUBSTRING() function returns a substring from any string you want. You can write the string explicitly as an argument, like this: SELECT SUBSTRING('This is the first substring example', 9, 10) AS substring_extraction;
1 mar 2021 · In this article, we explore SUBSTRING, PATINDEX, and CHARINDEX using examples. The SUBSTRING () function extracts the substring from the specified string based on the specified location. Syntax for SUBSTRING () function: SUBSTRING (expression, starting_position, length) starting_position: It contains an integer or bigint expression.
This example uses the SUBSTRING() function to extract domain from email addresses of customers: SELECT email, SUBSTRING ( email, CHARINDEX ('@', email)+ 1, LEN (email)-CHARINDEX ('@', email) ) domain FROM sales.customers ORDER BY email; Code language: SQL (Structured Query Language) (sql)
Extract a T-SQL substring with our easy-to-follow, detailed walkthrough. Enhance your string manipulation skills for better data handling.
28 lip 2021 · How to select rows where a text column starts by, ends by, or contains a string. Including slightly less trivial cases. To find strings that match a pattern, the LIKE operator is used. In the most trivial case, LIKE is identical to the = operator. These two queries are the same: SELECT id FROM book WHERE title LIKE 'Don Quijote';
13 sie 2020 · Let's suppose you want to select a substring from the start of the expression, or from the end. From the start, you can just enter 1 for the start parameter, but you can also use the shorthand function LEFT. The following two SQL statements are functionally equivalent: