Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

SET ROWCOUNT and table variable Expand / Collapse
Author
Message
Posted Wednesday, August 25, 2010 8:40 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:57 AM
Points: 2,587, Visits: 2,443
Comments posted to this topic are about the item SET ROWCOUNT and table variable
Post #975310
Posted Wednesday, August 25, 2010 8:51 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 11:47 AM
Points: 1,676, Visits: 1,759
This is an excellent question, thank you. I answered it correctly because for years I cannot find the answer to the following question: why would anyone ever consider casually using float data type? I understand that there might be some specific scenarios where the inaccuracy of calculations are not important and the range of the numbers is huge, but using float for no good reason is astonishingly bad not to say plain silly. The query in Qotd is one fine example demonstrating this point.

Oleg
Post #975312
Posted Wednesday, August 25, 2010 9:57 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, September 5, 2014 2:00 PM
Points: 2,160, Visits: 2,191
Thanks for the question, I had to puzzle it out for a while, but got it right.
Post #975324
Posted Wednesday, August 25, 2010 10:47 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 9:11 PM
Points: 1,940, Visits: 1,171
for testing folating point the same can be written as

DECLARE @i float,@rc int
set @i = 0
while @i <> 1
begin
set @i = @i + 0.1
end
select @i

then the loop never executes.

I observer some intrested behavior of floating point


DECLARE @i float,@rc int
set @i = 0
while @i <> 1
begin
set @i = 0.8999 + 0.1
end
select @i

the above will never executes. we use 0.1 instead of 0.8999 other wise we can use 0.2,0.3,0.4,0.5,0.6,0.7,0.8.but when i added 0.9 it executes

and show 1 as answer.



Malleswarareddy
I.T.Analyst
MCITP(70-451)
Post #975345
Posted Wednesday, August 25, 2010 10:54 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, October 30, 2014 1:38 AM
Points: 5,235, Visits: 390
The answer was almost obvious from the "do not run it on production server" recommendation.

But, a good question for highlighting the pitfalls of "float".



Cheers,
- Mark
Post #975349
Posted Wednesday, August 25, 2010 11:42 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 2:07 AM
Points: 4,101, Visits: 5,456
The only possible use for the float datatype that I have found is in the calculations used in astro-physics, where the distance between stars and galaxies is an approximation, at best

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #975366
Posted Thursday, August 26, 2010 12:32 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 4:18 PM
Points: 17,947, Visits: 15,940
Thanks for a great question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #975384
Posted Thursday, August 26, 2010 1:03 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 7:39 AM
Points: 13,522, Visits: 11,312
Great question. I got it wrong though. I do not really understand how the scope of the type variable works. It seems you can define it over and over again, without an error being thrown?



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #975393
Posted Thursday, August 26, 2010 1:03 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 2:40 AM
Points: 1,843, Visits: 507
Very interesting question and great explanations. Thanks
Post #975394
Posted Thursday, August 26, 2010 1:33 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 4:04 AM
Points: 176, Visits: 567
isn't it possible to use approximation if one is not specific of the exact value of the approximation, like "less than" and "greater than" ?
Post #975405
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse