I was trying to create a table as follows,
create table table1(date1 datetime,date2 datetime);
First I tried inserting values as below,
I had this issue when trying to concatenate getdate() into a string that I was inserting into an nvarchar field.
I did some casting to get around it:
INSERT INTO [SYSTEM_TABLE] ([SYSTEM_PROP_TAG],[SYSTEM_PROP_VAL]) VALUES
(
'EMAIL_HEADER',
'111 Any St.
Anywhere, ST 11111
' +
CAST(CAST(getdate() AS datetime2) AS nvarchar) +
'
'
)
That's a sanitized example. The key portion of that is:
...' + CAST(CAST(getdate() AS datetime2) AS nvarchar) + '...
Casted the date as datetime2, then as nvarchar to concatenate it.