Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ryoka012
Starting Member
20 Posts |
Posted - 2013-08-16 : 00:21:26
|
Hi,I have a scenario which i must check if the value of the inputted word is exact(case sensitive) in a string.And print the word if correct.using a user defined function.Example:The quick brown fox jump over the lazy dog.If the user enter "jump" it must print "jump".If the user enter "Jump" it must print "jump" which is the correct word.Thanks. |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-16 : 02:35:51
|
[code]DECLARE @str VARCHAR(50) = 'The quick brown fox JuMp over the lazy dog.'DECLARE @searchStr VARCHAR(10) = 'jump'IF ( @str LIKE '%'+@Searchstr+'%') SELECT SUBSTRING ( REPLACE (@str, LEFT(@str, CHARINDEX(@searchStr, @str)-1), ''), 1, LEN(@searchStr))[/code]--Chandu |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-16 : 02:57:28
|
[code]DECLARE @str VARCHAR(50) = 'The quick brown fox JuMp over the lazy dog.'DECLARE @searchStr VARCHAR(10) = 'jump'IF ( @str LIKE '%'+@Searchstr+'%' COLLATE LATIN1_GENERAL_BIN) SELECT SUBSTRING ( REPLACE (@str, LEFT(@str, CHARINDEX(@searchStr, @str)-1), ''), 1, LEN(@searchStr))[/code] Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
ryoka012
Starting Member
20 Posts |
Posted - 2013-08-16 : 05:40:09
|
thanks Bandi. just hit tje spot. |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-16 : 05:48:11
|
quote: Originally posted by ryoka012 thanks Bandi. just hit tje spot.
Welcome--Chandu |
|
|
|
|
|
|
|