how to find number of columns in a table in sql server 2000
and 2005 also
Answers were Sorted based on User's Feedback
Answer / harshad
select count(*) from information.schema.columns
where table_name='tablename'
//where tablename is name of your sql table.
//do not prefix table name with .dbo
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / mohan
Guys.. Why don;t you try for the Columns bided with User
Defined Data Type and try the above queries... and Also try
for the Auto incremented Columns..(Identity)....
Your opinion would change definately....
Try out...
I am sure it doesn't take account of UDT Binded Coulmns
Is This Answer Correct ? | 3 Yes | 2 No |
Answer / ajit kumar nayak
select count(*) from syscolumns sy,Sysobjects so
where
sy.id =so.id
and so.name = <table name>
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ram&saran
SELECT COUNT(*) FROM SYS.COLUMNS WHERE ID=(SELECT * FROM
SYS.OBJECT WHERE NAME='TABLENAME')
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / laxmi reddy
SELECT COUNT(COLUMN_NAME) FROM ALL_TAB_COLS WHERE
TABLE_NAME=<'TABLE_NAME'>;
Is This Answer Correct ? | 0 Yes | 0 No |
Explain how many normalization forms?
Why should we go for stored procedures? Why not direct queries?
How to reaname table name without using sp_Rename in sql server..?
Where do we generally create INDEX?
1 Answers Ernst Young, Thomson Reuters,
What is index fragmentation in ms sql server?
Does partitioning help performance?
hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.
What are constraints in microsoft sql server?
what is the diffrence between Snap Shot and Transaction Replication
In what sequence sql statement is processed?
What is oltp (online transaction processing)?
Questions on identity?