SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Inner Join on Varchar fields
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ciupaz
Posting Yak Master

Italy
176 Posts

Posted - 01/10/2013 :  08:08:46  Show Profile  Reply with Quote
Hello all,
I have 2 tables with a Varchar(100) fields, something like these:


TableA
TableA_ID - Value - Description - Value2
1 - 23 - 'City1 Gr. 1' - 300
2 - 25 - 'City1 Gr. 2' - 340
3 - 33 - 'City2 Gr. 1' - 320
4 - 13 - 'City3 Gr. 1' - 308




TableB
TableB_ID - Value - Description - Value2
1 - 63 - 'City1 Gr. 1' - 500
2 - 75 - 'City1 Gr. 2' - 540
3 - 63 - 'City2 Gr. 1' - 520
4 - 83 - 'City3 Gr. 1' - 508

Is it possible join them with the varchar fields?

Thanks in advance.


Luigi

PS
I'm using SQL Server 2008 R2

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 01/10/2013 :  08:58:47  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Yes.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Ciupaz
Posting Yak Master

Italy
176 Posts

Posted - 01/10/2013 :  09:26:25  Show Profile  Reply with Quote
It does not work, maybe for culture o accent impostations?

Luigi
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

3821 Posts

Posted - 01/10/2013 :  13:26:28  Show Profile  Reply with Quote
Are you saying the varchar COLUMNs have different collations?
Go to Top of Page

wholesalenfljerseyssale
Starting Member

9 Posts

Posted - 01/11/2013 :  01:17:14  Show Profile  Reply with Quote
Our company are professional wholesaler for Nike NFL Jerseys. We wholesale all kind of jerseys, include NFL, NHL, MLB, NBA and NCAA. All stitched on numbers and names, also with authentic packing jerseys for sale at our site. Huge stock for all kind of jerseys, also full way guaranteed for your goods. Wholesale NFL jerseys, basketball jerseys, hockey jerseys will be our speciality business. We are offical jerseys supplier and manufacturer for all leagues. So you will get correct style, best quality, best service from our site. Thanks for reading and enjoy your shopping! Only Wholesale jerseys at our site!
Enjoy shopping for the NFL Jerseys Wholesale online sale and cheap NFL jerseys from China in the professional China NFL jerseys outlet.high quality, lowest
Attention Clearance Sale fans! Use the Clearance Sale Categories below to purchase Clearance Sale Apparel, Clearance Sale Gifts and Clearance Sale Merchandise. We are your Jerseys for sale for all the authentic Clearance Sale Gear. Because you are a Clearance Sale fanatic you should have only the best licensed Clearance Sale Apparel guaranteed to show your Clearance Sale Pride. Fanzz only carries licensed Clearance Sale Jerseys, Clearance Sale T-Shirts, Clearance Sale Hats and Clearance Sale Drinkware for all Clearance Sale Players.


Attention Clearance Sale fans! Use the Clearance Sale Categories below to purchase Clearance Sale Apparel, Clearance Sale Gifts and Clearance Sale Merchandise. We are your Jerseys for sale for all the authentic Clearance Sale Gear. Because you are a Clearance Sale fanatic you should have only the best licensed Clearance Sale Apparel guaranteed to show your Clearance Sale Pride. Fanzz only carries licensed Clearance Sale Jerseys, Clearance Sale T-Shirts, Clearance Sale Hats and Clearance Sale Drinkwar
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 01/11/2013 :  03:02:48  Show Profile  Reply with Quote
quote:
Originally posted by Ciupaz

It does not work, maybe for culture o accent impostations?

Luigi


first check if contents are exactly same without any additional non printable characters

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

Go to Top of Page

Ciupaz
Posting Yak Master

Italy
176 Posts

Posted - 01/11/2013 :  03:06:09  Show Profile  Reply with Quote
Yes, they have, I think, differente collations.

Luigi
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 01/11/2013 :  03:09:46  Show Profile  Reply with Quote
then overide them using COLLATE in join like

SELECT *
FROM tablA a
JOIN TableB b
ON b.Description COLLATE database_default = a.Description COLLATE database_default


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

Go to Top of Page

Ciupaz
Posting Yak Master

Italy
176 Posts

Posted - 01/11/2013 :  03:33:32  Show Profile  Reply with Quote
This works. Thank you very much Visakh.

Luigi
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 01/11/2013 :  03:37:38  Show Profile  Reply with Quote
welcome

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000