Nils Gustav Stråbø (12/9/2010)
I don't like questions like this, and not because I got it wrong.
It teaches me nothing about Sql Server or T-SQL (except debugging peculiar T-SQL), and to be able to answer it correctly, without cheating, you will have to manually write down how many rows are inserted in each run of the loop in order to keep track of the number in the meaningless "SomeNumberForDate" column.
No, you don't need to do that.
You can see that 512 is greater than 365, so the last rows added have SomeNumberForDate = 256. Before that the last row added; and number of rows adsded before then was clearly 256 (it's all in poowers of two, obviously). There are 365 rows in all and and 256 with SomeNumberForDate 128 or less, and that leaves just 109 that have SomeNumberForDate = 256.
All you have to see is that the number of rows added each time is a power of 2, that the number of rows in teh table after each set is added is a power of 2, that there are 365 days in the year 2010, and that 512 is the smallest power of two greater than 365. No manually writing down meaningless numbers required.
I guess that learning to thing mathematically is a bit like learning to think set-oriented: is you don't learn it you end up doing things the hard way.
If it had been a question designed to check people's ability to do simple maths, it would have been a good question; but as it was apparently meant to teach something about SQL, it didn't achieve its objective. But there's some good SQL in the comments, so it was at least a useful question.