|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, June 08, 2012 12:30 AM
Points: 150,
Visits: 3,892
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 4:33 AM
Points: 5,241,
Visits: 7,049
|
|
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
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: 2 days ago @ 9:31 AM
Points: 1,040,
Visits: 1,356
|
|
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.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, March 09, 2010 11:48 AM
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
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 9:02 AM
Points: 1,046,
Visits: 573
|
|
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
|
|
|
|