Hi, I have a doubt regarding datatype. I have a employee table where it has attributes like, emp id int, salary money, name varchar(10). I want to know the data types as my query result of my table.Is there any way I can get the datatpe result using "select" command? Thanks & Regards, Ravi
select a.[Name], b.name, a.max_lengthfrom sys.columns ajoin sys.types bon a.user_type_id = b.user_type_idwhere [object_id] = object_id('your_table_name')order by column_id
An alternate option is to query from INFORMATION_SCHEMA.Columns. You can filter by TABLE_SCHEMA and TABLE_NAME You can also use sp_Help <table name>
Unless you are querying through some weird abstraction layer or some fancy querying tool, the data types in your result set will be the same as defined in the base tables. Of course, only if you don't do any conversion in your query... []