Search
 
SCRIPT & CODE EXAMPLE
 

SQL

reindex mssql table

-- mssql use to determine what indexes need to be rebuilt
SELECT S.name as 'Schema',
T.name as 'Table',
I.name as 'Index',
DDIPS.avg_fragmentation_in_percent,
DDIPS.page_count
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS DDIPS
INNER JOIN sys.tables T on T.object_id = DDIPS.object_id
INNER JOIN sys.schemas S on T.schema_id = S.schema_id
INNER JOIN sys.indexes I ON I.object_id = DDIPS.object_id
AND DDIPS.index_id = I.index_id
WHERE DDIPS.database_id = DB_ID()
and I.name is not null
AND DDIPS.avg_fragmentation_in_percent > 0
ORDER BY DDIPS.avg_fragmentation_in_percent desc
Comment

PREVIOUS NEXT
Code Example
Sql :: generate random data in mysql 
Sql :: how to completely uninstall sql server 
Sql :: import mysql command line 
Sql :: postrgesql concat 2 columns divided by ; 
Sql :: sql where multiple values 
Sql :: concatenation in sql 
Sql :: import sql file to mysql db using shell commands 
Sql :: how to find columns with null values in sql 
Sql :: view column type sql server 
Sql :: sql alter table 
Sql :: redirection 301 htaccess nom de domaine 
Sql :: sql searching via key word 
Sql :: mysql multiple left joins on same table 
Sql :: SQL Switch Databases 
Sql :: Kill session in SQL Developer 
Sql :: delete sql 
Sql :: mysql earlier than date 
Sql :: tables in sql 
Sql :: set up mssql in mac m1 
Sql :: sql strip non alphanumeric characters 
Sql :: how to print out column name differently in mysql 
Sql :: xampp mysql problem detected port 3306 in use by 
Sql :: sql except query 
Sql :: select * from 
Sql :: like postgres 
Sql :: mysql procedure 
Sql :: non relational database 
Sql :: use table postgres 
Sql :: sql int vs integer 
Sql :: trncate table with relationships 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =