CategorySQL

Post relating to SQL, T-SQL and SQLServer

SQL Server check table fragmentation level

S

If you are using SQL Server, and discover that what should be a simple select query, or particularly multiple select queries that are unioned together with a sort are running slowly, then the issue is your table indexes. This is particularly the case when using Date and DateTime fields for sorting. If you are trying to sort a table or multiple tables by Date, then it is a good idea to add an...

SQL Server – List all tables and the fragmentation percentage

S

This is another check you should perform once databases start to get large, as having fragmented indexes have a huge performance hit. For more on what fragmented indexes are, read this fantastic article. After significant trial and error we have come up with an SQL script that lists all indexes for every table and shows the percentage fragmentation for the selected database on your server in one...

SQL Server – checking if any tables don’t have a primary key

S

Its easily done, in the rush to create tables someone forgets to tell the auto-number field that it is also a primary key. Its not an issue until the database gets big, at which point (as listed on Microsoft TechNet) the performance can suffer by anything between 13% and 460% – which is potentially crippling for your database. Thankfully there is a simple SQL script you can run to double...

Archive

Tags

Get in touch

I'm available on just about every social media platform out there as RMTWeb.