Re: how to make case sensitive query

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Uri Dimant (urid_at_iscar.co.il)
Date: 11/29/04


Date: Mon, 29 Nov 2004 10:04:17 +0200

Suresh
It seems that I did not understand your requirements
Here is another one written by Itzik Ben-Gan

CREATE FUNCTION dbo.fn_capitalize
(
@str AS nvarchar(100)
)
RETURNS nvarchar(100)
AS
BEGIN

DECLARE
@ret_str AS varchar(100),
@pos AS int,
@len AS int

SELECT
@ret_str = N' ' + LOWER(@str),
@pos = 1,
@len = LEN(@str) + 1

WHILE @pos > 0 AND @pos < @len
BEGIN
SET @ret_str = STUFF(@ret_str,
@pos + 1,
1,
UPPER(SUBSTRING(@ret_str,@pos + 1, 1)))
SET @pos = CHARINDEX(N' ', @ret_str, @pos + 1)
END

RETURN RIGHT(@ret_str, @len - 1)

END

"Uri Dimant" <urid@iscar.co.il> wrote in message
news:OIlMJPe1EHA.1296@TK2MSFTNGP10.phx.gbl...
> Suresh
> There are some examples
> create table ABCD
> (
> [id]smallint not null,
> description varchar(20) null
> )
> insert into ABCD([id],description)values (1,'DFh2AcZ')
> insert into ABCD([id],description)values (2,'dHZ3')
>
> )
>
> SELECT description FROM ABCD where charindex(cast('H' as
> varbinary(20)),cast(description as varbinary(20)))> 0
>
> SELECT description
> FROM ABCD
> WHERE description ='dhZ3'COLLATE Latin1_General_BIN
>
> SELECT description
> FROM ABCD
> WHERE charindex('h',description COLLATE Latin1_General_BIN)>0
>
>
>
>
>
> "Suresh" <Suresh@discussions.microsoft.com> wrote in message
> news:AA1AC827-DA0D-421E-9118-662848C0AB7C@microsoft.com...
> > I need to retrive the a case sensitive value from a string.
> > like select All_Capital_Alphebets("This Is My String")
> > Expected result : "TIMS" (ie all capital letters from the string.
> >
> > How can i achieve this.
> >
> > Thanks in advance
> >
> > Suresh
>
>



Relevant Pages

  • Re: __asm access global variable
    ... int efgh; ... this line doesn't read abcd value correctly. ... Are these other functions members of class aaaa, ...
    (microsoft.public.vc.language)
  • Processes memory
    ... Hi all, given this simple snippet, can you explain me how the kernel is ... able to isolate the 's2' variable. ... int main ... Parent s2: ABCD, address: 0xbff078a4 ...
    (comp.unix.programmer)
  • Inserting a char into a string.
    ... char buffer; ... The variable buffer has been filled with four characters. ... How do I now make str equal to buffer? ... ie I have "ABCD" in buffer and I would like "ABCD" in str. ...
    (comp.lang.cpp)
  • Re: how to make case sensitive query
    ... SELECT description FROM ABCD where charindex(cast('H' as ... WHERE charindex('h',description COLLATE Latin1_General_BIN)>0 ... > I need to retrive the a case sensitive value from a string. ...
    (microsoft.public.sqlserver.programming)