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
 FULL OUTER JOIN Uniq?

Author  Topic 

jjmusicpro
Yak Posting Veteran

79 Posts

Posted - 2010-02-11 : 19:30:47
I wanted to make it so the items i joing on, the db_user_id and the ad_user_id to be unique matches.

Right now, if its JOE = JOE it works if its JOE = JOe it works

I want it to be case sensative any ideas on this?

SELECT	l.db_user_id,
l.db_location,
l.db_first_name,
l.db_last_name,
l.db_middle_name,
l.db_status,
l.db_school,
l.db_school_type,
r.ad_user_id,
r.ad_location,
r.ad_first_name,
r.ad_last_name,
r.ad_middle_name,
r.ad_status,
result = CASE
WHEN l.db_user_id = r.ad_user_id AND l.db_location = r.ad_location AND l.db_first_name = r.ad_first_name AND l.db_last_name = r.ad_last_name AND l.db_status = r.ad_status AND l.db_middle_name = r.ad_middle_name THEN 0
WHEN l.db_user_id = r.ad_user_id AND l.db_location <> r.ad_location OR l.db_first_name <> r.ad_first_name OR l.db_last_name <> r.ad_last_name OR l.db_middle_name <> r.ad_middle_name THEN 1
WHEN r.ad_user_id IS NULL THEN 2
WHEN l.db_user_id IS NULL THEN 3
END
FROM student_table_1 l
FULL OUTER JOIN student_table_2 r ON l.db_user_id = r.ad_user_id

Sachin.Nand

2937 Posts

Posted - 2010-02-11 : 22:56:43
What Collation has been set for your database?

PBUH
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-02-11 : 23:03:12
See the difference below


select 'joe'COLLATE Latin1_General_CS_AS
union
select 'JOe'

select 'joe'COLLATE Latin1_General_CI_AS
union
select 'JOe'


PBUH
Go to Top of Page

jjmusicpro
Yak Posting Veteran

79 Posts

Posted - 2010-02-12 : 00:53:31
i dont think ive set collication, can i make my database always case specific?

or can i set up only certin columns like my 2 i join on to be case specific?
i only need the column i join on to be case specific
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-12 : 01:08:39
quote:
Originally posted by jjmusicpro

i dont think ive set collication, can i make my database always case specific?

or can i set up only certin columns like my 2 i join on to be case specific?
i only need the column i join on to be case specific


you can do both by changing collation

if you want to make your db case sensitive, then use a case sensitive collation for db like Latin1_General_CS_AS
if you want to make a column alone to be case sensitive use case senstitive collation for it keeping collation of db as case insensitive

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -