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
 SQL Server Development (2000)
 Column list

Author  Topic 

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-06-12 : 06:15:04
how can get the column list from SQL query?
or how can i get the column names from specific table?

thanks in advance,

Mahesh

BMahesh

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-06-12 : 06:18:54
select c.Name, c.colid from
syscolumns c
inner join sysobjects o
on c.id = o.id and o.xtype = 'u'
where o.name = 'Your_table_name'
order by c.colid


Duane.
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-06-12 : 06:23:43
thanks Duane,


BMahesh
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-12 : 06:28:40
Select column_name from Information_Schema.Columns
where table_name='YourTable'

Madhivanan

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

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-06-12 : 06:30:47
thank Madhivanan

BMahesh
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2006-06-12 : 10:59:09
sp_help tablename will do the trick for you.It will show you the datatype,length everything in it.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-12 : 11:05:12
quote:
Originally posted by ayamas

sp_help tablename will do the trick for you.It will show you the datatype,length everything in it.


Information_Schema.Columns View also has those details

Madhivanan

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

- Advertisement -