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.
| Author |
Topic |
|
kbdrand
Starting Member
14 Posts |
Posted - 2003-06-05 : 08:31:13
|
| Is there a functional or performance difference between using <> '' and NOT LIKE '' in a SELECT statement? I have to place some SQL statements into a XML file and I really don't want to use <> if I can avoid it since I'll have to deal with encoding/decoding, etc. So I thought I would use NOT LIKE '' instead. I realize that NOT LIKE 'some value' and <> 'some value' are not the same since NOT LIKE would catch 'some value is not here' while <> would only catch the exact match, but for a blank entry it seems like they perform about the same.Is there something I'm missing, or do they really act about the same when dealing with blank values? |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-06-05 : 08:45:31
|
Just use != and you are good to go. It is the same as <>. C++ nerds like to use that syntax in SQL instead of <> to show how smart they are. Beware: None of NOT LIKE or <> or != works with NULL values. You need to use IS NOT NULL.- Jeff |
 |
|
|
kbdrand
Starting Member
14 Posts |
Posted - 2003-06-05 : 09:02:45
|
| Yeah, I thought about != but I've had some issues with it in the past on some certain SQL implementations (Not SQL Server). So I got used to using <>. I'll give != a shot. |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2003-06-05 : 11:37:08
|
| With NOT LIKE you can use wild card characters which isnt possible using either != or <>. -------------------------What lies behind you and what lies ahead of you are small matters compared to what lies within you.-Ralph Waldo Emerson |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2003-06-05 : 12:04:14
|
| With != or <> you have a better chance of performing an index seek. with NOT LIKE, you may not even use and index, and if you do it will be an index scan. As stated in an earlier post, NOT LIKE can use wildcards, where <> or != does not.-ecEdited by - eyechart on 06/05/2003 12:10:44 |
 |
|
|
|
|
|