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 |
|
wgpubs
Yak Posting Veteran
67 Posts |
Posted - 2004-06-14 : 18:26:36
|
| Is there a way to do it? Basically want to use the CHARINDEX function in a case-sensitive way.eg. SELECT CHARINDEX( 'b' , 'abdf' ) = 2 but SELECT CHARINDEX ( 'B' , 'abdf' ) = 0Thanks - wg |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-06-14 : 18:41:10
|
| declare @i int, @j intselect @i = 0, @j = 0while @i <> 1 and @j <> 1beginselect @i = @i + 1select @i = charindex('b',@str,@i)If @i <> 0beginif convert(binary(1),substring(@str,@i,1)) = convert(binary(1),'b') select @j = 1endselect @i = @i + 1endselect case when @j = 1 then 'found' else 'not found' end==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-06-14 : 18:41:56
|
| [code]SELECT CHARINDEX ( convert(varbinary,'b') , convert(varbinary,'abdf') )SELECT CHARINDEX ( convert(varbinary,'B') , convert(varbinary,'abdf') )[/code] |
 |
|
|
wgpubs
Yak Posting Veteran
67 Posts |
Posted - 2004-06-14 : 19:01:01
|
cool thanks. I thought about this before but wasn't sure it would work cuz of the binary conversion. - wgquote: Originally posted by ehorn
SELECT CHARINDEX ( convert(varbinary,'b') , convert(varbinary,'abdf') )SELECT CHARINDEX ( convert(varbinary,'B') , convert(varbinary,'abdf') )
|
 |
|
|
|
|
|
|
|