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.
| Author |
Topic |
|
SanjaySutar
Starting Member
18 Posts |
Posted - 2008-05-05 : 01:01:34
|
| Hi is there any way to find no. of columns in a database tablelike we can do that in Oracle by typing DESC tablenameSan |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-05 : 01:15:03
|
| SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'YourTable' |
 |
|
|
vivekroberts
Starting Member
2 Posts |
Posted - 2008-05-05 : 02:23:22
|
| select count(*)from syscolumnswhere id = ( select id from sysobjects where name = 'Your Table') |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-08 : 04:29:50
|
quote: Originally posted by vivekroberts select count(*)from syscolumnswhere id = ( select id from sysobjects where name = 'Your Table' and xtype='u')orselect count(*)from syscolumnswhere id = object_id('Your Table')
MadhivananFailing to plan is Planning to fail |
 |
|
|
Anoop
Starting Member
6 Posts |
Posted - 2008-05-08 : 04:46:36
|
| instead of syscolumns use sys.columns if using SQL Server 2005.select count(*)from sys.columnswhere object_id = ( select object_id from sys.tables where name = 'Your Table') |
 |
|
|
eralper
Yak Posting Veteran
66 Posts |
Posted - 2008-05-08 : 07:03:34
|
| Hi,We can go further by using Object_ID() function as followsselect count(*) from sys.columns where object_id = object_id('table_name')-------------Eralperhttp://www.kodyaz.com |
 |
|
|
|
|
|