'Search a table field for a subscript of a string in SQL server
I have a table which looks like this:
**Description**
North
East
West
South
Now if I want to search the table in the column description using a subscript of a string like for example I want to search the value North but the available string I have is "ValueNorth"
its like this sample SQL:
SELECT Description FROM Table1 WHERE Description = 'ValueNorth'
Now what I want to display in the result is the value of North in the description.
Is it possible in SQL server.
Thanks for the help
Solution 1:[1]
Um it's very hard to understand what you are asking but is this what you are looking for?
SQL> SELECT SUBSTRING('Quadratically',5,6);
+---------------------------------------------------------+
| SUBSTRING('Quadratically',5,6) |
+---------------------------------------------------------+
| ratica |
+---------------------------------------------------------+
1 row in set (0.00 sec)
as you can see it cuts up the string, more examples here: http://www.tutorialspoint.com/sql/sql-string-functions.htm#function_substring-index
Solution 2:[2]
You can compare the value percentage matching between two values and then get the results based on the condition.
This may help you.
Solution 3:[3]
try this:
SELECT replace (Description,'Value','') FROM Table1 WHERE Description = 'ValueNorth'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Le Green |
Solution 2 | Community |
Solution 3 | hassan kamarzadeh |