CFLib.org – Common Function Library Project

MSSQLInt(number)

Last updated April 1, 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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson