Useful T-SQL snippets for development and troubleshooting

This post is more of a note-to-self. These are the useful T-SQL statements which can be incredibly useful in development and troubleshooting

Turn on the IO statistics for statements run after that until set to OFF explicitly. We then switch to Messages tab to see how many IO operations were done on each table.

Find out about the statements were executed: which statements, its texts, how many reads (logical), how many time was spent on CPU and how many time was spent total

Get the index fragmentation level, order by the most fragmented ones:

To drop the cached execution plan of a stored procedure, which is very useful to check if that specific stored procedure is suffering from parameter sniffing problem or not:



Leave a Reply