0
CREATE TABLE comments (
    content VARCHAR(100),
    created_at TIMESTAMP DEFAULT NOW()  
);

The error message

'NOW' is not a recognized built-in function name.

Progman
  • 16,827
  • 6
  • 33
  • 48
  • Please add the full error message (including the error code) and the result of select version(); – P.Salmon Aug 16 '22 at 15:03
  • Started executing query at Line 1 Msg 195, Level 15, State 10, Line 3 'NOW' is not a recognized built-in function name – Oseyomon Osajele Aug 16 '22 at 15:21
  • 1
    Msg 195, Level 15, State 10 is a sql-server error message and is correctly telling you that now() does not exist. - I think sql-server equivalent is getdate() or you are pointing to the wrong server.. – P.Salmon Aug 16 '22 at 15:26
  • 1
    The tsql TIMESTAMP datatype is likely not what you want. That is a deprecated datatype and is now just a synonym for [ROWVERSION](https://learn.microsoft.com/en-us/sql/t-sql/data-types/rowversion-transact-sql?view=sql-server-ver16) - which has no relationship to date or time. – SMor Aug 16 '22 at 19:11

1 Answers1

0

NOW() is not ansi-standard sql.

Given this is a SQL Server error message, I'll say that SQL Server people tend to use getdate() instead. However, the actual standard is current_timestamp, which FWIW is supported on both SQL Server and whichever of MySql or Posgresql you were using before, albeit they both treat is as a function (you need parentheses) while SQL Server treats it as a keyword (no parentheses).

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794