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.
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>.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.