I believe you meant "not" rather than "now".
However, your first example is also non-deterministic. Here's the proof.
Create table dbo.SalesOrderHeader (RN INT IDENTITY(1,1),SomeDate DATETIME);
GO
ALTER TABLE dbo.SalesOrderHeader ADD WhichDay AS datepart(day,'20180131') PERSISTED;
Msg 4936, Level 16, State 1, Line 1
Computed column 'WhichDay' in table 'SalesOrderHeader' cannot be persisted because the column is non-deterministic.
Here an example where it is deterministic:
DROP table dbo.SalesOrderHeader
Create table dbo.SalesOrderHeader (RN INT IDENTITY(1,1),SomeDate DATETIME NOT NULL);
ALTER TABLE dbo.SalesOrderHeader ADD WhichDay AS datepart(d,SomeDate) PERSISTED;
create index idx_SalesOrderHeader ON SalesOrderHeader(WhichDay)
Commands completed successfully.
The difference is the second input parameter:
with string is non-deterministic
with a valid datetime is deterministic
Wow, that just gave me a headache.LOL But hey I forgot the deterministic rule. OLD AGE is A bummer.
Thanks for the schooling!
Paul