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
 General SQL Server Forums
 New to SQL Server Programming
 plz help any one!

Author  Topic 

raky
Aged Yak Warrior

767 Posts

Posted - 2008-02-26 : 07:49:04
hi
in which sys objects the datatype of the colunn is stored????
how can i get the datatypes and column names of the specified table.

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2008-02-26 : 07:50:36
sp_help YOURTABLE


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-02-26 : 07:53:59

SELECT COLUMN_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='Your Table Name'

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-26 : 07:55:03

or

EXEC sp_columns 'your table'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-02-26 : 07:55:27
I want to get result set columnname and datatype.
I want query for that and I use that in another query.
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-02-26 : 07:58:56
thanks
I got the result.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-26 : 07:59:56
quote:
Originally posted by raky

I want to get result set columnname and datatype.
I want query for that and I use that in another query.


Then use the query suggested by Pravin

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-02-26 : 08:00:10
Which solution did u use?
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-02-26 : 08:01:52
open up the sql code for "sp_help" on master db.
You'll find it all there.
Go to Top of Page

ranganath
Posting Yak Master

209 Posts

Posted - 2008-02-26 : 08:15:28
hi,

if u want to see all Tables information then use this

select Distinct s.name as schema_name, t.name as table_name, c.name as column_name, st.name AS DataType, c.length, c.xprec, c.xscale, c.cdefault
from sys.syscolumns as c
join sys.tables as t
on t.object_id = c.id
join sys.schemas as s
on s.schema_id = t.schema_id
inner join SysTypes ST on ST.xusertype = c.xusertype
Go to Top of Page
   

- Advertisement -