I have a table with a nvarchar(32) column and I want to update the value in this column with the first 10 bytes of another field on the table which is defined as nvarchar(32) after the 10 bytes I want to concatenate the first 22 bytes of the current datetime without the dashes in the date.
Update Bil_ReturnsRepository
Set PaymentReference = CAST((Left(PolicyNumber, 10) + CONVERT(datetime,GETDATE(), 121)) as nvarchar
Where PolicyNumber = '1234567890'
I would like for the output to look like this for example:
1234567890201802130446386883
Left(PolicyNumber, 10)
could result in less than 10 characters. It should probably be changed toCAST(Left(PolicyNumber, 10) AS NCHAR(10))