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

后端 未结 2 1396
温柔的废话
温柔的废话 2020-12-23 20:27

I have a website that does inserts into this table below. I need to do some manual inserts but I wasn\'t sure how do pass in the equivalent of DateTime.Now in C#.

相关标签:
2条回答
  • 2020-12-23 20:32

    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 讨论(0)
  • 2020-12-23 20:57

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

    0 讨论(0)
提交回复
热议问题