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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Compare string problem

Author  Topic 

TeresitaCastro
Starting Member

2 Posts

Posted - 2010-01-04 : 19:06:07
Hi!

I have a table with two rows:

Status Type
'Fin' 'S'
'FIN' 'S'

When I make a join with the colum Status, if the value is 'FIN' it return two colums, how can I do to make the quey ditinct betweent FIN and Fin

Where Clause Expected result
Fin=FIN False
FIN=FIN True

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2010-01-04 : 19:12:07
how manu statuses do you have? you might be trying to solve a design problem with a another weak solution approach. why do you have Fin FIN in the first place? can you change that?

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2010-01-05 : 00:57:06
see this link
http://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/

DECLARE @t TABLE (Status VARCHAR(32),Type VARCHAR(1))
INSERT INTO @T SELECT 'Fin', 'S' UNION ALL
SELECT 'FIN', 'S'

SELECT *, CASE WHEN Status COLLATE Latin1_General_CS_AS = 'FIN' THEN 'True' ELSE 'False' END Cond
FROM @t
Go to Top of Page

balaganapathy.n
Starting Member

18 Posts

Posted - 2010-01-05 : 01:27:44
A small note to add: If your have installed your SQL Server with Collition like %_CS_AS (case sensitive & Accent sensitive) then what you're expecting will occur automatically during join.

balaganapathy n.
Go to Top of Page
   

- Advertisement -