Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Wild Join Question


Wild Join Question

Author
Message
Carleton
Carleton
SSC-Enthusiastic
SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)SSC-Enthusiastic (158 reputation)

Group: General Forum Members
Points: 158 Visits: 3892
Comments posted to this topic are about the item Wild Join Question
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8311 Visits: 11538
Carleton (12/23/2009)
If you are unsure if the field contains a wildcard character when joining using the LIKE operator, you can avoid false positive results by observing this tip:

But what is the point of using LIKE if you do this? Why not simply use the = operator?


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
sknox
sknox
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2030 Visits: 2708
Hugo Kornelis (12/24/2009)
Carleton (12/23/2009)
If you are unsure if the field contains a wildcard character when joining using the LIKE operator, you can avoid false positive results by observing this tip:

But what is the point of using LIKE if you do this? Why not simply use the = operator?


In general, you probably wouldn't use LIKE exactly like that, but with your own wildcards attached. For example, you may want to see if a string contains another string in its entirety. If the second string might have a wildcard in it, you'd have to do something like:


select * from #table1 t1
inner join #table2 t2
on t1.Col1 like
'%' + REPLACE(REPLACE(t2.Col1,'%','[%]'),'_','[_]') + '%'




Otherwise, the wildcard in the second string may cause false positives.
Chris Carter-210078
Chris Carter-210078
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 52
The complete answer should be “It depends”. If you have a case sensitive collation designator you will get:
Msg 208, Level 16, State 0, Line 3
Invalid object name '#table1'.
Since the script created a table #Table1 and tries to reference #table1
BudaCli
BudaCli
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1166 Visits: 598
Chris Carter-210078 (12/30/2009)
The complete answer should be “It depends”. If you have a case sensitive collation designator you will get:
Msg 208, Level 16, State 0, Line 3
Invalid object name '#table1'.
Since the script created a table #Table1 and tries to reference #table1
You're correct but based on what's given then you'll need to set collation to something that will provide with results for this scenario.

What you don't know won't hurt you but what you know will make you plan to know better
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search