Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How could you know how many columns you have in your table

Status
Not open for further replies.

CDuffy

MIS
Feb 28, 2001
4
ES
Hi everybody,

As you can see I am starting with SQL 7 and I would like to know if it exist a query which can automaticaly tell you how many columns you have in your table.

this is to be able to calculate the Null Bitmap.
thanks for your information
Patrick :cool:
 
try this one...

declare @tbl varchar(50)
set @tbl = 'Tablename'
select NumberOfColumns = count(name) from syscolumns where id = (select id from sysobjects where name = @tbl)


or this...


declare @tbl varchar(50)
set @tbl = 'Tablename'
select NumberOfColumns = info from sysobjects where name = @tbl


Andel
andelbarroga@hotmail.com
 
Cheers Andel, it is exactly what i was looking for.
Patrick :cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top