GO gettging error msg like: 消息102,级别15,状态1,行2 '('。解决方案 附近的语法不正确请尝试以下语法: ALTER TABLE TABLENAME ADD CONSTRAINT CONSTRAINTNAME DEFAULT GETDATE() FOR COLUMNNAME 尝试 ALTER 表 DOMAIN ADD CONSTRAINT dt_1 DEFAULT GETDATE() FOR CREATED_DATE , CONSTRAINT dt_2 DEFAULT GETDATE() FOR LAST_UPDT_DATE GO Hi,I want to apply current system date and time to two columns (created_date ,last_updated_date). How to use default constraint for this requirement?thanks in advance.What I have tried:ALTER TABLE DOMAINADD CONSTRAINT dt_1 DEFAULT GETDATE() FOR (CREATED_DATE,LAST_UPDT_DATE)GOgettging error msg like:Msg 102, Level 15, State 1, Line 2Incorrect syntax near '('. 解决方案 Try this syntax:ALTER TABLE TABLENAMEADD CONSTRAINT CONSTRAINTNAME DEFAULT GETDATE() FOR COLUMNNAMETryALTER TABLE DOMAINADD CONSTRAINT dt_1 DEFAULT GETDATE() FOR CREATED_DATE , CONSTRAINT dt_2 DEFAULT GETDATE() FOR LAST_UPDT_DATEGO 这篇关于如何为sql中的两列应用当前systemdate添加默认约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-21 02:02