I'm playing with a loop, trying to measure which select statment would be faster: Select partcost * quantity orSelect Total(The total field already contains partcost * quantity.)There is only one record in the table (Parts): Record 1
PartName varchar(20) Part 1partcost smallmoney 12.0000 Quantity int 5Total smallmoney 60.0000
Here is the test code for the first SELECT I'm running - it takes over 10 seconds on my machine.set nocount ondeclare @tempans smallmoneydeclare @start datetimedeclare @end datetimedeclare @loopcount intset @loopcount = 0set @start = getdate()while @loopcount < 1000begin set @loopcount = @loopcount + 1 set @tempans = (select (partcost * quantity) from parts)endset @end = getdate()set nocount offselect @startselect @end
Can anybody tell me why this runs soooo slow ?Thanks,Kevin