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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any one know an SQL command that.....

Status
Not open for further replies.

elziko

Programmer
Nov 7, 2000
486
GB
Hi guys,

I've got an SQL book but am unable to find a command which will return the data type of a particular field or of a particular piece of data. Is this possible?

If not in SQL is there any other way? I'm using ADO by the way.

Many thanks,

elziko
 
There's no standard SQL which will do this. Some of the database mfrs *might* have an extension which does this.

But, what we've done is this:
[tt]
Public Function FindFieldType(ByVal lTypeCode As Long) As String

Select Case lTypeCode
Case 129, 130, 200, 201, 202, 203
FindFieldType = "char"
Case 2, 3, 4, 16, 17, 18, 19, 21, 131, 139
FindFieldType = "int"
Case 6
FindFieldType = "money"
Case 7, 133, 134, 135
FindFieldType = "datetime"
Case 11
FindFieldType = "bool"
Case 5, 14
FindFieldType = "double"
End Select
End Function
[tt]

And to use it, you just call it like this:
[tt]
sFieldType = FindFieldType(adoRS.Fields("MyField").Type)
[/tt]
I think it even works if the field is <NULL>.

Chip H.

 
Chip,

Spot On! I was trying to do something with the data returned by &quot;desc&quot; but was not having much luck.

Thanks:)

elziko
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top