Repeating rows based on a value in a different column

I’ve just replied to a question in dotnethell italian forum about the topic in the title. Actually it’s not the first time I got this kind of question:

“How can I repeat a row using a value that is stored in another column of the same table?”

Ok, let’s describe a solution step by step.

Differences between SSMS and query execution time

Sometimes, in the forums I’m following, I face some questions about different execution times between Sql Server Management Studio and executions.

Questions like “Why my SSMS queries run so fast and my queries are so slow?”. This is a scaring behavior that you can verify lots of times. Some application’s logs tell to us a too large timing. When you copy/paste the SQLCommand into a new query window using SSMS (also on the incriminated server) the execution time is very short.

Continue reading “Differences between SSMS and query execution time”