TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
SQL Table Fragmentation Percent
Ashish Srivastava
May 22, 2016
4.1
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog you will learn SQL table Fragmentation Percent.
Query:
DECLARE
@
Database
NVARCHAR(128)
DECLARE
@
Table
NVARCHAR(128)
SET
@
Database
= N
'MYDATABASE'
-- Database
SET
@
Table
= N
'dbo.ProposalForm'
-- Table
SELECT
I.
name
,
ROUND(S.avg_fragmentation_in_percent, 2)
AS
FragmentationPercent
FROM
sys.dm_db_index_physical_stats (DB_ID(@
Database
), OBJECT_ID(@
Table
)
,
NULL
,
NULL
,
NULL
) S
INNER
JOIN
sys.indexes I
ON
S.object_id = I.object_id
AND
S.index_id = I.index_id
Output:
SQL Table
SQL
Fragmentation Percent
Next Recommended Reading
Create Table, Select, Insert, Update, Delete Table In SQL