Jason Huang said:
In my SQL Server 2000, is it possible to know the size of a particular
table in a database?
What do you mean by "the size"? If it is just the number of rows, then a
simple "Select Count(*) from TheTable" will return that value. If your
problem is that you don't know how to send that query from C# into the Sql
Server, just ask here again and we will give you some sample code.
However, if you need something more detailed, such as the number of Data
Pages allocated or Data Pages in use by the table, then you will need to
perform a complex Select joining various system tables (in sql server 2008
it would be a select from sys.allocation_units joined on the container_id
column to sys.whatever-maps-the-sys.tables-into-sys.allocation_units; I
don't have a sql server 2000 on hand to verify this). One way to find out
the precise query that you need to execute is to start Sql Server Profiler
so that it captures queries sent to the server. You then use Sql Server
Management Studio (or Enterprise Manager) to display the Properties of the
Table until you see the Size information that you wanted to know. You then
go back to the Profiler and there you find which was the query that the
management tool sent into the server to fetch that information. If you copy
that query and send it to the server from your C# client code, you will get
back the same information. There is your size data.