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)
 Highest number of columns

Author  Topic 

vin
Starting Member

26 Posts

Posted - 2003-04-01 : 00:14:55
Hi folks,
How to find out which table in my database has highest number or columns and i need to get the number of columns in that table and store that value in a variable.


samsekar
Constraint Violating Yak Guru

437 Posts

Posted - 2003-04-01 : 00:51:50
HTH..

Declare @MaxNoOfColumns int
Select @MaxNoOfColumns=Max(C.TotalColumns)from
(
select B.name as TableName,B.id as TableID, count(A.name) as TotalColumns
from SysColumns as A Inner Join SysObjects as B
on A.id=B.id and B.type='u'
group by B.name, B.id
) as C
Select @MaxNoOfColumns as Max_No_Columns

Sekar
~~~~
Success is not a destination that you ever reach. Success is the quality of your journey.
Go to Top of Page

vin
Starting Member

26 Posts

Posted - 2003-04-01 : 01:17:02
thanx sam

Go to Top of Page
   

- Advertisement -