Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


ISINTEGER function


ISINTEGER function

Author
Message
AFPeterson
AFPeterson
SSC Veteran
SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)SSC Veteran (258 reputation)

Group: General Forum Members
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?
jsm-1077063
jsm-1077063
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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
DPhillips-731960
DPhillips-731960
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1158 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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search