Oseyomon Osajele
Oseyomon Osajele

Reputation: 1

Trying to create a TIMESTAMP type, the NOW() function is not working on my Azure DATA studio

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

The error message

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

Upvotes: 0

Views: 840

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 416149

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).

Upvotes: 0

Related Questions