Sql – equivalent of PostgreSQL type “timestamp without time zone” in SQL Server

postgresqlsqlsql server

what is the type equivalent of postgresql "timestamp without time zone" in SQL Server?

would it be ok to use DateTime?

Best Answer

For new development you can use the datetime2 data type, not the "plain" datetime. It stores a timestamp with no time zone, and lets you specify the precision that you need for your system.

To get the precision of 1 microsecond, which is the equivalent of timestamp without time zone in PostgreSQL, you need to specify precision of 6 fractional digits, i.e.

datetime2(6)

See this answer for details on why Microsoft recommends using datetime2.