IDNUMBER >= '1000205830' and IDNUMBER <= '1000206010' ORDER BY ID_NUM DESC
I'm also getting IDNUMBER 1000206 included in the range?
IDNUMBER >= '1000205830' and IDNUMBER <= '1000206010' ORDER BY ID_NUM DESC
I'm also getting IDNUMBER 1000206 included in the range?
IDNUMBER >= '1000205830' and IDNUMBER <= '1000206010' ORDER BY ID_NUM DESC
Here you should use cast as int
IDNUMBER >= cast ( '1000205830' as int )
IDNUMBER <= cast('1000206010' as int )
Then it should work
Data type of idnumber should also be int
thanks much appreciated! I'll give this a try.
If IDNUMBER is a char/varchar column, then you can't realistically do a numeric comparison on it. You should do a comparison that would be valid for a char/varchar column:
WHERE IDNUMBER >= '1000205830' and IDNUMBER <= '1000206010' AND LEN(IDNUMBER) = 10
You can try casting the original column to int, but:
If you insist on CASTing the column -- and I don't recommend it -- CAST to a bigint instead.
another thing is .. Performance ,,..
YOU CAN CREATE AN INDEX
...just on those rows you are comparing ...
Its called filtered index .. only on this part
IDNUMBER >= '1000205830' and IDNUMBER <= '1000206010'
Filtered Index is a new feature in SQL SERVER . Filtered Index is used to index a portion of rows in a table that means it applies a filter on INDEX which improves query performance, reduces index maintenance costs, and reduce index storage costs compared with full-table indexes .
hi ifor
thanks for unexpected side effect
please suggest any alternatives !!!!!
I was able to get what I needed from this post. Thanks everyone much appreciated!