Aug 26, 2002 #1 dky1e Programmer May 4, 2002 293 US Is there a funtion to test if a string contains a character specified? Similar to IndexOf function in .net sdk? Here's my pseudo code: declare @test select @test = 'asdf' if indexOf( @test, 'a' ) > 0 begin do stuff end
Is there a funtion to test if a string contains a character specified? Similar to IndexOf function in .net sdk? Here's my pseudo code: declare @test select @test = 'asdf' if indexOf( @test, 'a' ) > 0 begin do stuff end
Aug 26, 2002 #2 Niv3k Programmer Jul 11, 2001 350 US PRINT patindex ('%[A-Za-z]%','123a') will return 4 PRINT patindex ('%[A-Za-z]%','123') will return 0 Upvote 0 Downvote
Aug 26, 2002 #3 Niv3k Programmer Jul 11, 2001 350 US So if you are looking for 'a' replace the %[A-Za-z]% with %a% for case insensitive do %[Aa]% Use both % (wildcards in SQL) unless you want a field that starts with a: [aA]% or ends with a: %[Aa] Upvote 0 Downvote
So if you are looking for 'a' replace the %[A-Za-z]% with %a% for case insensitive do %[Aa]% Use both % (wildcards in SQL) unless you want a field that starts with a: [aA]% or ends with a: %[Aa]
Aug 26, 2002 Thread starter #4 dky1e Programmer May 4, 2002 293 US how would I use it if I am using variables? How do I use the '%' character? Upvote 0 Downvote
Aug 26, 2002 Thread starter #5 dky1e Programmer May 4, 2002 293 US here we go... I found an alternative. SELECT CHARINDEX('w', 'wonderful') Upvote 0 Downvote