What is best way to Concat on datetime column with other fields, without losing/truncate millisecond precision?
Example: We have a column in datetime precision.
We are creating rowhash on CONCAT
The problem when doing Concat, we are losing second values. You can test here,
create table dbo.SalesOrder ( SalesOrderId int primary key, SalesRecord varchar(255), SalesDatetime datetime ) select concat(SalesRecord,SalesDateTime) from dbo.SalesOrder select concat('ABC ',[SalesDateTime]) from dbo.SalesOrder ABC Feb 27 1988 12:00AM
What is the optimal way to solve this?
Background: Rowhash was causing duplicates by removing seconds, pipe deliminator | not working either.
The following was not working:
declare @testdate datetime = '1988-02-27 00:00:04.000' select concat('ABC',convert(binary(16),@testdate)) select concat('ABC',convert(varchar(25),@testdate))