cancel
Showing results for 
Search instead for 
Did you mean: 

Returning a column data-type for just one column in table

Former Member
0 Kudos

I know there is a way of returning all the metadata for a table including all the column types, but we have a slightly oddball situation where for one table depending upon the DB one column could either be a varchar or integer, therefore we need to validate a data-entry form to ensure strings are not entered where the data-type is integer

Is there any way, via SQL, to check the data-type just for a particular column?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member244518
Participant
0 Kudos

This data can be found in the system catalog using the SYSCOLUMNS view.

Query on sample database:


SELECT

    coltype

FROM

    SYS.SYSCOLUMNS

WHERE

    tname = 'Contacts'      // Table name

    AND creator = 'GROUPO'  // Table owner

    AND cname = 'PHONE'     // Column name

Result:


coltype

=====

char

Former Member
0 Kudos

Just the job 🙂

Thank you very much

Answers (0)