Answering a deleted question – “The multi-part identifier could not bound”

Stackoverflow question got deleted while I was writing the answer for the person who posted their question. May be he deleted it as he found answer or someone else deleted it as duplicate question. In any case, if he is still seeking help, I hope he finds the answer. I am posting here incase it … Continue reading Answering a deleted question – “The multi-part identifier could not bound”

Optimize for Statistics – Fixing Parameter Sniffing

What is Parameter Sniffing? When a parameterized query or stored procedure is some times slow and sometimes fast. This phenomenon is called parameter sniffing. I wanted to learn it and therefore I did some experiments. For this example, I am using Stackoverflow2013 database. I created following index so I don't end up sleeping while the … Continue reading Optimize for Statistics – Fixing Parameter Sniffing

SP to get number of rows between ranges without reading table

I was working on a parameter sniffing issue ended up trying to understand statistics for the table. But I found that regular method gives too much information DBCC SHOW_STATISTICS ('TABLE_NAME', 'STATISTICS_NAME') I wanted to deep dive more so I googled and found a better script SELECT hist.step_number, hist.range_high_key, hist.range_rows, hist.equal_rows, hist.distinct_range_rows, hist.average_range_rows FROM sys.stats AS … Continue reading SP to get number of rows between ranges without reading table