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 |
|
andre-gj
Starting Member
1 Post |
Posted - 2008-01-04 : 07:13:56
|
| Hi, I'm relatively new to writing sql. And I could need some help. I have a short code to pick the next available itemcode. The Itemcodes are mostly numeric, but I have a few that has a prefix. I want to exclude the Items with prefix. The statement below fails. but if I remove the last where condition I get the the next available number.Can any one help me get this statement to work with both conditions?select max(itemcode)+1 from OITM where LEFT(Itemcode,2)<>'z-' AND (itemcode between 1000001 and 9999999) |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-01-04 : 07:20:54
|
| [code]select max(itemcode)+1 (Select cast(itemcode as int) as itemcodefrom OITM where LEFT(Itemcode,2)<>'z-' ) t1Where itemcode between 1000001 and 9999999[/code]But frankly why don't use identity column instead?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|