I am trying to insert GETDATE()
value into a column with data type datetime2
. But I am getting following error. I am using Azure SQL database.
This error is specific to getdate() function that i uses. I have see similar question with same error message but that scenario was complete different.
CREATE TABLE [dbo].[test]
(
[procedureName] NVARCHAR(900) COLLATE Latin1_General_100_CI_AS_KS_WS NULL,
[configCreated] DATETIME2(7) NOT NULL,
[configModified] DATETIME2(7) NOT NULL
)
Any idea why I am getting this error? I tried in my local SQL Server database, it worked but not in my office. I tried best from my end.
Insert into dbo.ETLLoadConfig('abc',getdate(), getdate()) -- it fails in azure sql DB
even tried this also: with a as(select cast(getdate() as datetime2) as date1) Insert into dbo.ETLLoadConfig('abc',(select date1 from a), (select date1 from a))
insert values statement can contain only constant literal values or variable references