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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Small and Caps letter treated Same

Author  Topic 

rajivguptaahd
Starting Member

1 Post

Posted - 2009-08-13 : 11:12:44
I have table where there are two rows with same value , but one is in small letter and one is in Caps, like EMPLID = 'RX0001B' and 'RX0001b'. Now when I query the table , Select * from table XXXX where EMPLID = 'RX0001B', it retrieves both the rows. How to avoid this? I am new to MSS 2008.

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-08-13 : 11:25:22
Look up COLLATE in books on line or in the management stuido help

Here's an example to get you started

DECLARE @collations TABLE (
[vala] VARCHAR(255) COLLATE LATIN1_GENERAL_CI_AI -- Case Insensitive, Accent Insensitive
, [valb] VARCHAR(255) COLLATE LATIN1_GENERAL_CS_AS -- Case sensitive, Accent Sensitive
)

INSERT INTO @collations ([vala], [valb])
SELECT 'aaaa', 'bbBbb'
UNION ALL SELECT 'AAAA', 'bBBBB'

SELECT * FROM @collations WHERE [vala] = 'aaaa'
SELECT * FROM @collations WHERE [vala] = 'aaaa' COLLATE LATIN1_GENERAL_CS_AS

SELECT * FROM @collations WHERE [valb] = 'bbbbb'
SELECT * FROM @collations WHERE [valb] = 'bbBbb' COLLATE LATIN1_GENERAL_CI_AI



Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-08-13 : 11:52:46
Try this too


select * from table_name where cast(column_name as varbinary)= cast(@value as varbinary)

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page
   

- Advertisement -