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)
 like and equal to operator

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2010-02-11 : 05:39:46
Hi,

Is it possible in sql server 2005 to write something similiar to this:
where firstname like 'burno' (to return firstname= burno and not firstnames that contain the phrase burno)
Is this equivalent to where firstname='burno'?

Thanks

Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 05:44:30
if you want exact match use =

if you want pattern match use LIKE with wildcard characters like %,_,etc

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

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-11 : 06:00:30
Yes

where firstname like 'burno'

is equal to

where firstname ='burno'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-11 : 06:38:28
"is equal to"

Does SQL Query Planner optimise a LIKE, with no wildcard characters, to Equals? If not EQUALS will be better than LIKE in that scenario
Go to Top of Page
   

- Advertisement -