Tutorials to .com

Tutorials to .com » Database » Sqlserver » Lowercase

Lowercase

Print View , by: iSee ,Total views: 11 ,Word Count: 421 ,Date: Sun, 23 Aug 2009 Time: 10:05 PM

Lowercase

And 7.0 in the sql2000 query statement to distinguish between uppercase query methods

- sql2000, will use the following method.
- Field name is added collate Chinese_PRC_CS_AS_WS


- Case-sensitive, the whole method of half-width characters

- Test Data
create table Table (fd varchar (10))
insert into table
select aa = aa
union all select Aa
union all select AA - full-width A
union all select A, A - full-width A, half-angle,
union all select A, A - full-width A, full-width,
go

- Query
- 1. Zha uppercase letters
select * from table
where fd collate Chinese_PRC_CS_AS_WS like% A%
- Field name is added collate Chinese_PRC_CS_AS_WS

- 2. Zha full-width
select * from table
where fd collate Chinese_PRC_CS_AS_WS like% A%

- 3. Zha half-angle
select * from table
where fd collate Chinese_PRC_CS_AS_WS like%,%
go

- Delete the test data
drop table Table

/ *-- Test Results

1. Check the results of capital letters
fd
----------
Aa


2. Check the results of full-width characters
fd
----------
AA
A, A
A, A


3. Check the results of half-width characters
fd
----------
A, A

(Number of rows affected by a line)
--* /


================================================== ==============

- sql7 .0, will use the following method.

- If it is all the more
- Here is a test
select * from (
select fd = a
union all select A
) A
where cast (fd as varbinary (8000)) = cast (A as varbinary (8000))

/ *-- Test Results
fd
----
A

(Number of rows affected by a line)
--* /

- If it is part of the match, you use charindex:

- Here is a test
select * from (
select fd = a
union all select A
union all select aAaa
union all select aaaa
union all select cccA
) A
where charindex (cast (A as varbinary (8000)), cast (fd as varbinary (8000)))> 0

/ *-- Test Results
fd
----
A
aAaa
cccA

(The number of rows affected by 3 lines)
--* /





Microsoft SQL Server Tutorial Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.