use current date as default value for a column

后端 未结 8 814
心在旅途
心在旅途 2021-02-02 04:43

Is there a way to set the default value of a column to DateTime.Now in Sql Server?

Example:

table Event
Id int (auto-increment) not null
Des         


        
8条回答
  •  渐次进展
    2021-02-02 05:28

    Table creation Syntax can be like:

    Create table api_key(api_key_id INT NOT NULL IDENTITY(1,1) 
    PRIMARY KEY, date_added date DEFAULT 
    GetDate());
    

    Insertion query syntax can be like:

    Insert into api_key values(GETDATE());
    

提交回复
热议问题