How can we help you today? How can we help you today?
kipb7

Activity overview

Latest activity by kipb7

Slow startup under SSMS
Just did an update from a 2-year old version, to SQL Prompt 6.4.1.142. Happy with new features, thanks! But... Starting SQL Server Management Studio (SQL 2008 R2) takes a minute to start up. I'm ...
4 followers 6 comments 0 votes
MX1 - I'm sorry to say that having RedGate (RG) Support didn't do me any good. However, there are some work-arounds to the "can't sync floats" problem. - Use a view on each side that rounds the floats and then sync the views (I haven't done this but it was suggested by RedGate) instead of sync'ing the tables. The tables won't be exactly the same but they will look the same to RG. - Use decimal(20,16) etc. instead of float - but this requires that you know the range of your values in advance, and that you can stand the possibly larger data size. We've switched a lot of our floats to decimal to make sync easier and some other benefits. - Use a non-RedGate solution to sync the tables having floats. We've done this, in SQL 2008 using the MERGE statement over the network and it runs much faster than RG so we use it for the bulk of the sync and then run RG to see if we missed anything. This only works if SQL Server A can read data from SQL Server B, whereas RG only requires that the client machine running SQL Data Compare be able to see both A and B. (We use checksum of each end's table to know if it is worth doing the merge.) - Wave your hands and yell about how floats are only "approximate" and how can you expect them to blah blah and you shouldn't be using floats anyway and every programmer knows.... This is what we got so far including from Microsoft, whose sync tools have the same problems. - Use RedGate SQL Data Compare 9 as-is. This requires that you tolerate your floats being very close and not exact. When you re-compare, they'll look again like a sync is required, though the specific values look to be identical when printed in decimal. It is likely that this is OK for your application. "do sync; trust result." I hope you'll keep pushing RG to come up with a way to sync floats correctly. It's not easy as they need to have a way for A to output a string that B will convert to the identical binary value inside. I spent a few hours at it and couldn't come up with one that worked in every case, where the string was generated by a SQL expression. Converting binary float inside RG to an 18- or 20-digit decimal float will probably work. 17 significant digits isn't enough for all floats and that's all SQL Server will do. / comments
MX1 - I'm sorry to say that having RedGate (RG) Support didn't do me any good. However, there are some work-arounds to the "can't sync floats" problem. - Use a view on each side that rounds the fl...
0 votes
DECLARE @fa FLOAT = 1.0646328852929699e-2 DECLARE @fb FLOAT = 1.0646328852929700e-2 SELECT 'fa'[number], @fa [f], CONVERT(DECIMAL(25,20), @fa) [decimal] UNION SELECT 'fb'[number], @fb [f], CONVERT(DECIMAL(25,20), @fb) [decimal] UNION SELECT 'diff', (@fa-@fb), CONVERT(DECIMAL(25,20), @fa-@fb) --Output: number f decimal fa 0.0106463288529297 0.01064632885292970000 fb 0.0106463288529297 0.01064632885292970000 diff -1.73472347597681E-18 0.00000000000000000000 These two floats look identical if you use SQL Server 2008 R2's conversion to decimal, but they are not identical. While a float might approximate a particular real number, it is an exact binary value representing an exact number. It is reasonable to expect operations on it to give the closest answer and not resort to "but it's approximate!" Here the question is whether the decimal representation is the best available for reproducing that float when doing synchronization. SQL Server fails at this task. SQL Data Compare does not have to fail if it would use 17 significant decimal digits or transfer numbers in a different form. This problem is in addition to the earlier reported need for SQL Data Compare to specify that the data value is float by using E0 on the end, since SQL otherwise assumes it is decimal and incorrectly converts some numbers to float, such as 0.85195833333333271 versus 0.85195833333333271e0 which are not equal numbers to SQL. / comments
DECLARE @fa FLOAT = 1.0646328852929699e-2 DECLARE @fb FLOAT = 1.0646328852929700e-2 SELECT 'fa'[number], @fa [f], CONVERT(DECIMAL(25,20), @fa) [decimal] UNI...
0 votes
As we've seen earlier, many floats are not correctly synchronized by SQL Data Compare. Previously, it was suggested that appending e0 onto the end of a float would make SQL process it as a float instead of as a decimal. Here is a case where that does not work, and it may be an error in how Red Gate generates the decimal value for a float. create table dbo.FloatTest (PK INT PRIMARY key, Fraction FLOAT) insert into dbo.FloatTest (PK, Fraction) Values (1, 0.07689223240363979e0) DECLARE @F1 FLOAT SELECT @F1 = Fraction FROM dbo.FloatTest PRINT CONVERT(DECIMAL(17,17),@f1) --prints 0.07689223240363979 -- looks good, right? Also create this table on another database - but without the INSERT. Now use SQL Data Compare and see what value is generated: INSERT INTO [dbo].[FloatTest] ([PK], [Fraction]) VALUES (1, 0.0768922324036398) --This rounds to 16 places, it seems, or 15 significant figures. As in the original report, this is the incorrect binary value for the float. Here's the new part: adding on e0 is ALSO INCORRECT: INSERT INTO [dbo].[FloatTest] ([PK], [Fraction]) VALUES (1, 0.0768922324036398e0) So, would it be possible to get Red Gate Data Compare's Synchronize to synchronize floats correctly? We have been manually appending e0 onto floats for some months now when synchronizing. Now we see this is not enough. / comments
As we've seen earlier, many floats are not correctly synchronized by SQL Data Compare. Previously, it was suggested that appending e0 onto the end of a float would make SQL process it as a float in...
0 votes
You might enjoy the Microsoft response on this; It perhaps indicates that Red Gate should represent floats with E notation, not default decimal. Here is my report to Microsoft: --Some floats parse inconsistently: DECLARE @A FLOAT, @B FLOAT SET @A = 0.8519583333333327 SET @B = 0.85195833333333271 IF @A>@B PRINT 'Greater' --prints PRINT @A-@B --positive (expect 0 or negative) One can work around this either by appending 'E0' onto the end of the float or by using CONVERT(float,'0.85195833333333271'). The numbers above are equal using either. These also helped with about 10,000 other such cases. Here is the reply: "The behavior you are seeing is by design. When you specify a floating point value without the scientific notation, it is actually considered a decimal value not float. And you are then converting the decimal value to float which can result in rounding errors depending on the value. "In your case, the value for @A is represented by decimal(16, 16) and @B is represented by decimal(17, 17). As you discovered, you should use the scientific notation for specifying the floating point value. "Btw, you can determine the type of a constant by doing something like below: declare @v sql_variant = 0.8519583333333327; select sql_variant_property(@v, 'BaseType') , sql_variant_property(@v,'Precision') , sql_variant_property(@v, 'Scale'); -- Umachandar, SQL Programmability Team" / comments
You might enjoy the Microsoft response on this; It perhaps indicates that Red Gate should represent floats with E notation, not default decimal.Here is my report to Microsoft: --Some floats parse ...
0 votes