1

In a sql-server database with data I have several columns with type datetimeoffset(7). Now I would like to change the precision part of the type to datetimeoffset(0).

Is this possible without creating a new column of the desired type/precision and renaming the column?

I take solutions using SQL Server Management Studio as well as code (or also a no it's not possible).

1 Answer 1

6

This should be a straightforward

alter table tab
alter column x datetimeoffset(0);
2
  • This would work - Just remember that you are only saving 2 bytes going from 10 bytes for datetimeoffset(7) to 8 bytes datetimeoffset(0) so altering the table will not save you so much space msdn.microsoft.com/en-us/library/bb630289.aspx.
    – Spörri
    Commented Jun 2, 2015 at 11:24
  • 2
    It works. And it's not about the space but the unneeded precision causes pain at another level.
    – boutta
    Commented Jun 2, 2015 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.