CFLib.org – Common Function Library Project

MSSQLInt(number)

Last updated April 01, 2003

author

Michael Slatoff

Version: 1 | Requires: CF5 | Library: DatabaseLib

Description:
Checks to see if the number is a valid SQL-92 integer. If it is valid, return number else return 0.

Return Values:
Returns a number.

Example:

<!---
<cfquery name="EmployeeDetails" datasource="Intranet">
    SELECT
        EmployeeID, FirstName, LastName
    FROM
        Employees
    WHERE
        EmployeeID = <cfqueryparam value="#MSSQLInt(ATTRIBUTES.EmployeeID)#" cfsqltype="CF_SQL_INTEGER">
</cfquery>
--->

Parameters:

Name Description Required
number Number to check. Yes

Full UDF Source:

/**
 * Checks to see if the number is a valid SQL-92 integer.
 * Rewritten by RCamden. Code didn't work as submitted.
 * 
 * @param number      Number to check. (Required)
 * @return Returns a number. 
 * @author Michael Slatoff (michael@slatoff.com) 
 * @version 1, April 1, 2003 
 */
function MSSQLInt(number) {
    if (val(number) LT -2147483648 OR val(number) GT 2147483247) return 0;
    else return number;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson