Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to determine the datatype of a column in a table. 2

Status
Not open for further replies.

spr

Programmer
Nov 10, 2000
12
IN
I'm trying to build an SQL statement dynamically with a few where conditions. For the Where conditions, I select values from tables which are also built dynamically. Now, I want to identify the datatype of each column of the dynamically built table and build the statement. The datatype is required because that would decide the requirement of the '' (single quotes for char & varchar types) in the statement. Any suggestions?
Thanks in advance.
 
Hi,

You can obtain the information about the data type of the column using the information_schema.columns 'data_type' value...

Try executing this query to visualize it:
use pubs -- or whatever database
go

select *
from information_schema.columns
go

The data_type column used in this query can tell you what type the column has... the column in question is indicated by the column_name returned from the query...

Hope this helps...

Tom
 
Also, SPR, if you are doing this externally via ODBC, there is an ODBC function named SQLCOLUMNS() that may help as well.

Robert Bradley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top