Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
CREATE FUNCTION dbo.fnreturnDatetime (@SecondVal int)RETURNS DATETIMEASBEGIN DECLARE @Output Datetime SELECT @Output = DATEADD(SECOND,@SecondVal,'19700101'); RETURN @OutputENDI m using this in one of my columns create table tblTest( [CreatedDateTimeINT] [int] NULL, [CreatedDateTime] as (dbo.fnreturnDatetime([CreatedDateTimeINT])) PERSISTED ,)
The above works fine, but as soon as i add PERSISTED keyword, it throws an error -Computed column 'CreatedDateTime' in table 'tblTest' cannot be persisted because the column is non-deterministic.I don't think value in Createddatetime is non-deterministic because it will remain the same irrespective of the time it is executed.Am i missing something here?Thanks :)