Select count(*) From yourdatabase.sys.columns where object_id = OBJECT_ID('yourdatabase.dbo.tablename')