C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

Count


Posted Date: 31 Aug 2007      Posted By: mahitha      Member Level: Gold     Points: 2   Responses: 6



Sql command to count the no of columns in a table.




Responses

Author: sathiyasivam    31 Aug 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hi ,

In the system table you can find this yar. Please check the systable. I think it is syscolumn.

Regards
sathiya



Author: Shivshanker Cheral    01 Sep 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Select TABLE_CATALOG ,
TABLE_SCHEMA,
TABLE_NAME ,
COLUMN_NAME
From stars_db.Information_Schema.Columns
Where Table_Name like 'Table_Name'



Author: Shivshanker Cheral    01 Sep 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

to count use this
Select count(COLUMN_NAME)
From stars_db.Information_Schema.Columns
Where Table_Name like 'Table_name'

stars_db is database name and Table_name is table name which you want to count number of columns



Author: Padma    03 Sep 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi check this SELECT count(*) FROM INFORMATION_SCHEMA.columns WHERE table_name='tabTest'


Author: Padma    03 Sep 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi check this SELECT count(*) FROM INFORMATION_SCHEMA.columns WHERE table_name='tabTest'


Author: SUJITH     26 Sep 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

Hi Try this

select count(sc.name) from syscolumns sc,sysobjects so where sc.id=so.id and so.name ='tablename'



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Count(*) and Count(ColumnName)
Previous : syntax error converting varchar value '/' to a column of datatype int
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use