Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

ISINTEGER function Expand / Collapse
Author
Message
Posted Sunday, October 14, 2007 8:18 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, March 1, 2005 11:41 AM
Points: 258, Visits: 1
Comments posted to this topic are about the item ISINTEGER function


What's the business problem you're trying to solve?
Post #410610
Posted Monday, July 6, 2009 1:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 22, 2010 3:30 AM
Points: 1, Visits: 14
How do you take care of Maximum integer value ?

SELECT dbo.fn_ISINTEGER ('1234567891002')

gives 1 saying that it is valid int, but

SELECT CONVERT(INT,'1234567891002')

throws error
Post #747546
Posted Friday, December 23, 2011 10:54 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, August 10, 2012 6:08 PM
Points: 1,156, Visits: 801
Since the OP doesn't actually test the bounds of an specific integer type, it can be confusing. However, the Reg-Ex in the OP is nice, and I prefer to use it directly in my WHERE clause instead of a function, such as:

SELECT
1
WHERE
MyField NOT LIKE '%[^0-9]%'

Double-negeatives are... awesome... at least in this case.

To break it down, the LIKE + "^" with wildcard "%" surrounding the pattern returns true if *any* character in the test string set is not in the set of 0 to 9.
The NOT returns true only if the LIKE condition returns false.

However, one cannot just take out both of the negatives and get the same result, as the pattern would then only search to see if any single character in the string was a valid 0 to 9 digit, regardless if other characters in the test string set were not.

So, I
 SELECT 'LIKE' WHERE 'NOT' NOT LIKE '[^NOT]' 

(Result = 'LIKE'), and which backwards NOT is a ton spelled.
Post #1226330
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse