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 |
|
jesus4u
Posting Yak Master
204 Posts |
Posted - 2002-08-13 : 09:15:29
|
| Can u help me?How do I write this sql?I need to delete any records where Column1 NOT = 'PK' and Column2 NOT = '0.00' and Column3's FIRST character is the string '6'?Thanks |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-08-13 : 09:17:29
|
delete <table>where Column1 <> 'PK' and Column2 <> '0.00' and left(Column3,1) = '6' Jay White{0} |
 |
|
|
dsdeming
479 Posts |
Posted - 2002-08-13 : 09:18:30
|
| Try this:DELETE FROM tablenameWHERE Column1 <> 'PK' AND Column2 <> '0.00' AND LEFT( Column3, 1 ) = '6' |
 |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2002-08-13 : 10:21:46
|
quote: LEFT( Column3, 1 ) = '6'
Column3 LIKE '6%'LEFT doesn't produce sargable conditions (which is stupid, but there you go). |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-08-13 : 11:32:19
|
| assuming none of the fields are null.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
sql_learner
Starting Member
7 Posts |
Posted - 2002-08-14 : 05:20:07
|
| PATINDEX('%6%',Column3) > 0 runs faster than using LIKE |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-08-14 : 08:01:06
|
quote: PATINDEX('%6%',Column3) > 0 runs faster than using LIKE
And also doesn't meet the requirements...maybe you meanPATINDEX('6%',Column3) > 0Jay White{0} |
 |
|
|
|
|
|