Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Returning DATATYPE for columns

Author  Topic 

MarkyBoy666
Starting Member

14 Posts

Posted - 2004-12-15 : 06:36:27
I have a very simple problem, but one that I cannot find an answer for ANYWHERE on the net!

What I'm trying to do is return the datatype for a specific column in a table. Now, I know that you use COL_NAME('table','column') for column name, and COL_LENGTH('table','column') for the length. But I can't find anywhere what the syntax is for column data type! I'd be really grateful for any help.

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-12-15 : 06:41:28
don't know about the function but you can query it

select column_name,data_type from information_schema.columns where table_name='mytable'

--------------------
keeping it simple...
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-12-15 : 11:37:32
Check out sp_columns + sp_MShelpcolumns.
But the easiest way is to use the information_schema views.

rockmoose
Go to Top of Page
   

- Advertisement -