开发者

How do I do an insert with DATETIME now inside of SQL server mgmt studio

开发者 https://www.devze.com 2023-01-04 12:14 出处:网络
I have a website that does inserts into this ta开发者_如何学Goble below.I need to do some manual inserts but I wasn\'t sure how do pass in the equivalent of DateTime.Now in C#.

I have a website that does inserts into this ta开发者_如何学Goble below. I need to do some manual inserts but I wasn't sure how do pass in the equivalent of DateTime.Now in C#.

I am running this below from the query editor in SQL server mgmt studio. Is there any way to pass in the current date time in this query below.

INSERT INTO [Business]
           ([IsDeleted]
           ,[FirstName]
           ,[LastName]
           ,[LastUpdated]
           ,[LastUpdatedBy])
     VALUES
           (0, 'Joe', 'Thomas', 
           ,<LastUpdated, datetime,>
           ,<LastUpdatedBy, nvarchar(50),>)


Use CURRENT_TIMESTAMP (or GETDATE() on archaic versions of SQL Server).


Just use GETDATE() or GETUTCDATE() (if you want to get the "universal" UTC time, instead of your local server's time-zone related time).

INSERT INTO [Business]
           ([IsDeleted]
           ,[FirstName]
           ,[LastName]
           ,[LastUpdated]
           ,[LastUpdatedBy])
     VALUES
           (0, 'Joe', 'Thomas', 
           GETDATE(),  <LastUpdatedBy, nvarchar(50),>)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号