SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Schema Compare is unaware of DATETIME2 precision

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Schema Compare is unaware of DATETIME2 precision
Author Message
bdill



Joined: 12 Jun 2025
Posts: 2
Country: United States

Post Schema Compare is unaware of DATETIME2 precision Reply with quote
SQL Assistant 13.0.56 Professional Edition

I frequently use DATETIME2(0) to reduce the number of bytes consumed and because I don't need precision more than 1 second.
If I need more precision I use DATETIME2(2) to get to the 1/100th of a second and still save a byte compared to the legacy DATETIME data type.

However, SQL Assistant 13's Schema Compare appears to be unaware of the precision of the DATETIME2 data type.

Is there a setting I'm missing somewhere, or is this a bug/deficiency of SQL Assistant 13.0.56 Professional Edition
Thu Jun 12, 2025 3:54 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
I'm unable to understand from your description what kind of issue you are facing. A screenshot would be very helpful as well as mentioning types of databases compared and their specific versions as that might be important too.

And yes, most things can be customized in the Schema Compare tool, but first we need to understand what exactly isn't working for you.
Thu Jun 12, 2025 7:54 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2170

Post Reply with quote
My guess is that he complains about not removing the zeros for the fraction seconds when using datetime2(0), which will end in result sets like this (left column):



You could do that by modifying/changing the display formats:



and picking Hide zero fraction



However, that's still very far from being perfect (you have to do that for every column manually), and the Format input (by default) only allows formatting hours/minutes/seconds and has no settings (that I know of, but I should check the user guide) for fractional seconds, meaning that unless you change the Display Format, the SA result pane will display times with 3 decimal points of fraction seconds regardless of the result being that precise or not. It also only shows those 3 fraction decimals when the datetime2 is defined to be more precise than that (right column, with datetime2(6).



And I think that discrepancy makes two, otherwise equal values to be considered unequal (and/or vice verse) resulting in false negatives/positives in the comparison.
Fri Jun 13, 2025 6:52 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
I think you are referring to what would be relevant to the Data Comparison feature, while the original post is referring to Schema Comparison...
Fri Jun 13, 2025 8:48 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2170

Post Reply with quote
Yes, I misread that. But what I want to point out is that SA/SE does already (seemingly) disregard (in some cases) that some data types might have precision/length/width/whatever, so the root cause might be common.
Fri Jun 13, 2025 11:56 am View user's profile Send private message
bdill



Joined: 12 Jun 2025
Posts: 2
Country: United States

Post Reply with quote
gemisigo

Quote:
Yes, I misread that. But what I want to point out is that SA/SE does already (seemingly) disregard (in some cases) that some data types might have precision/length/width/whatever, so the root cause might be common.


This. Sorry for lack of detail. I'm referring to the Schema Compare (using SQL Server)




The generated code is unaware that I chose "0" as the precision of my datetime2().

Likewise if one column was datetime2(0) and the other was datetime2(7), Schema Compare would NOT detect a difference.


Fri Jun 13, 2025 3:05 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
So now it's clear, you would like to show/compare datetime2 scales. Here is how you can have it

In SQL Assistant Options navigate to "Schema Compare" tab
In the left top list select "SQL Server"
In the list below find and select "Columns (min version 13)", note this list item name not Columns for older versions
On the right side, in the Query section below case for decimal and number, add the following

Code:
WHEN t.[name] IN ('datetime2', 'datetimeoffset', 'time') AND c.scale <> 7
               THEN '(' + CONVERT(varchar, c.scale) + ')'


Apply changes, restart your development tool, whichever you use. After that, scale of datetime2 and time data types is going to be compared too



Sat Jun 14, 2025 10:52 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.