Shannon,
You can run sp_columns *tablename* on the table. It returns a query with a
datatype column. Here's a sample UDF that may help a little. It uses the
"DATA_TYPE" column from the stored proc. It could just as easiy be written
to use the "TYPE_NAME" column (that would have made it more readable. I use
this function to set the correct type in <cfqueryparam> (as in <cfqueryparam
cfsqltype="#converdatatype(intDattype)#" value="#blah#">). This UDF doesn't
cover all the types (it was written for a specific ap and set of tables) but
you get the idea.
function convertDataType(intDtype) {
var strReturn = '';
SWITCH(intDtype)
{
CASE '4': { strReturn = 'CF_SQL_INTEGER'; break; }
CASE '1': { strReturn = 'CF_SQL_CHAR'; break; }
CASE '11': { strReturn = 'CF_SQL_DATE'; break; }
CASE '3': { strReturn = 'CF_SQL_DECIMAL'; break; }
CASE '2': { strReturn = 'CF_SQL_NUMERIC'; break; }
CASE '6': { strReturn = 'CF_SQL_FLOAT'; break; }
}
return strReturn;
}
-mk
-----Original Message-----
From: Shannon Carr [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 20, 2002 9:56 AM
To: CF-Talk
Subject: Getting datatype before SELECT
Does anyone know of a way to determine the datatype of a column in a SQL
database before running a cfquery?
I have created a dynamic query and need to determine the datatype of
ColumnList fields before executing a query. If a person enters text and the
table column is an integer the page breaks and visa-versa.
Thanks,
Shannon Carr
[EMAIL PROTECTED]
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists