如何在sql server 2008 r2中从数据库插入当前时间的查询 [英] how insert query in current time from database in sql server 2008 r2
本文介绍了如何在sql server 2008 r2中从数据库插入当前时间的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sql server 2008中从数据库插入查询当前时间r2
解决方案
create table tbl_test(id bigint ,currentdate datetime 默认 getdate())
insert tbl_test( id)值( 1 )
或
创建 table tbl_test1(id bigint ,currentdate datetime )
insert tbl_test1(id,currentdate)值( 1 ,GETDATE())
这取决于哪个您希望在表格中为DATETIME插入值的格式,以下是几个示例:
CREATE table expDateTime
(
UnconvertedDateTime datetime ,
UsingCast nvarchar ( 50 ),
OnlyDate datetime
)
将 插入 expDateTime (UnconvertedDateTime,UsingCast,OnlyDate)
VALUES (GETDATE(),CAST(GETDATE() AS nvarchar ( 50 )), CONVERT ( date ,GETDATE()))
GO
how insert query in current time from database in sql server 2008 r2
解决方案
create table tbl_test(id bigint,currentdate datetime default getdate()) insert tbl_test (id) values (1) or create table tbl_test1(id bigint,currentdate datetime ) insert tbl_test1 (id,currentdate) values (1,GETDATE())
This depends in which format you want to insert value for DATETIME in your table, here are few examples:
CREATE table expDateTime ( UnconvertedDateTime datetime, UsingCast nvarchar(50), OnlyDate datetime ) Insert into expDateTime( UnconvertedDateTime, UsingCast, OnlyDate) VALUES(GETDATE(),CAST(GETDATE() AS nvarchar(50)), CONVERT (date, GETDATE())) GO
这篇关于如何在sql server 2008 r2中从数据库插入当前时间的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文