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 |
sonjan
Starting Member
22 Posts |
Posted - 2013-01-17 : 19:50:02
|
HiI am trying to write a script to retrieve all fuel transactions that are not in multiple locations.Example:select * from fueltrans with (nolock) where location not like ('%capalaba%','%ormiston%','%thorneside%')Appreciate feedback.ThanksSonja |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2013-01-17 : 19:59:24
|
Depends on whether you want not to have all 3 or either one.If either one you can change it to ORSelect * from fueltrans with (nolock) Where (location not like '%capalaba%') AND (location not like '%ormiston%') AND (location not like '%thorneside%') |
|
|
sonjan
Starting Member
22 Posts |
Posted - 2013-01-17 : 20:02:53
|
Thank you, it was to include all suburbs listed.Sonja |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-17 : 22:34:25
|
[code]select f.* from fueltrans fjoin (select 'capalaba' as cat union all select 'ormiston' union all select 'thorneside' )ton f.location not like '%' + t.cat + '%'[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2013-01-18 : 12:55:47
|
Using NOT LIKE will force a scan through all possibilities.There are probably more efficient ways. You're using NOLOCK in your initial query. If you're also issuing updates , inserts this could cause dirty reads. Is that intended behaviour?Jack Vamvas--------------------http://www.sqlserver-dba.com |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2013-01-19 : 03:27:48
|
keep in mind if you're to implement READ_COMMITTED_SNAPSHOT isolation level there is added pressure on the tempdb. Tempdb can potentially be a serious bottleneck.Of course , it is possible to tune the tempdb , such as the type of storage , file numbers etchttp://www.sqlserver-dba.com/2011/04/tempdb-performance-and-strategy-checklist.htmlJack Vamvas--------------------http://www.sqlserver-dba.com |
|
|
|
|
|