Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

need help

$
0
0

Hi All,

I need aquery to find page count of table in sql server.as below query is returning more than one value for each table

SELECT

sch.name,

    t.NAMEAS TableName,

    p.rowsAS RowCounts,

    a.total_pages AS PAGES,

   SUM(a.total_pages)* 8 AS TotalSpaceKB,

    SUM(a.used_pages)* 8 AS UsedSpaceKB,

    (SUM(a.total_pages)-SUM(a.used_pages))* 8 AS UnusedSpaceKB

FROM

    sys.tables t

INNERJOIN     

    sys.indexes iON t.OBJECT_ID= i.object_id

INNERJOIN

    sys.partitions pON i.object_id= p.OBJECT_IDAND i.index_id = p.index_id

INNERJOIN

    sys.allocation_units aON p.partition_id= a.container_id

INNERJOIN

     sys.schemas schon sch.schema_id=t.schema_id

WHERE

    

   t.is_ms_shipped= 0

   AND i.OBJECT_ID> 255

GROUPBY

    sch.name,t.Name, p.Rows

ORDERBY

    t.Name

   


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>