|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
SUBSTRING equivalent for a number/integer?
When data was in Oracle I used the following command to grab the last 4 digits of a number no matter how large the number was:
SUBSTR(field1, -4) This grabbed the right-most 4 digits (i.e., 6789 from the number 123456789) Now that the data is in SQL Server I can't use SUBSTRING because TSQL doesn't allow SUBSTRING against a number/integer. What function can I use to pull the last 4 digits of a number? This will be used in a query like this: WHERE SUBSTR(field1, -4) = #form.number# Last edited by kathyh1 : July 30th, 2008 at 09:16 AM. Reason: misspelling |
|
#2
|
||||
|
||||
|
Aside from the fact that I consider it horrible that Oracle actually supports an abomination like that, I wonder why you don't just use the modulo (%) function:
WHERE (field1 % 10000) = #form.number#
__________________
This is my code. Is it not nifty? "The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools." ---Douglas Adams Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 278
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > SUBSTRING equivalent for a number/integer? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|