CURRENT_TIMESTAMP例子:USE pubs GO CREATE TABLE sales2 ( sales_id int IDENTITY(10000, 1) NOT NULL, cust_id int NOT NULL, sales_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, sales_amt money NOT NULL, delivery_date datetime NOT NULL DEFAULT DATEADD(dd, 10, GETDATE()) ) GO INSERT sales2 (cust_id, sales_amt) VALUES (20000, 550)
我只要日期和时间,不要毫秒 抱歉阿,手头没有API文档 sun的网页好慢
在default里写: cast(CONVERT(varchar(19), getDate(),120) as datetime)
设计表-->在default写入 getdate()你插入的时候:insert TableName (除了时间列) values(除了时间列的值)
GO
CREATE TABLE sales2
(
sales_id int IDENTITY(10000, 1) NOT NULL,
cust_id int NOT NULL,
sales_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
sales_amt money NOT NULL,
delivery_date datetime NOT NULL DEFAULT DATEADD(dd, 10, GETDATE())
)
GO
INSERT sales2 (cust_id, sales_amt)
VALUES (20000, 550)
抱歉阿,手头没有API文档
sun的网页好慢
cast(CONVERT(varchar(19), getDate(),120) as datetime)
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108) ---06:05:05