P.Brian.Mackey
P.Brian.Mackey

Reputation: 44275

Get data type without the UI

Is it possible to obtain the datatype of a column without clicking through the UI?

I would like to be able to do...

SELECT SQLGetTypeInfo(TableName.ColumnName)

returns int

I need this to declare my own variables when debugging parameterized queries. I found SQLGetTypeInfo on IBM's website, doesnt work in SSMS 2008.

Upvotes: 1

Views: 209

Answers (1)

juergen d
juergen d

Reputation: 204746

You can put that in a procedure or function if you don't want to call it as query:

SELECT DATA_TYPE 
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'TableName'
and COLUMN_NAME = 'ColumnName'

Upvotes: 2

Related Questions