In SQL 2008 and 2005 a simple SQLCLR function that leverages the TryParse method of the Int32 object is the most complete way to check for whether a string value can be cast to a SQL INTEGER. Here is a SQLCLR for you:
[font="Courier New"]using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlBoolean IsInt32(SqlString Input)
{
if (Input.IsNull)
return SqlBoolean.False;
else
{
Int32 i;
return Int32.TryParse(Input.Value, out i);
}
}
}
[/font]
It is worth noting that in SQL 2012 the TRY_PARSE function was added to T-SQL language making this a trivial chore.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato