How do I populate a column with GETDATE?

  • I have to create a table where one column is populated using GETDATE(). How do I add that in to this code correctly?

    create table mytable

    (

    UserLogIDInt IDENTITY(1,1) NOT NULL,

    UserDomainnvarchar(50),

    LoggedUsernamenvarchar(50),

    AccessDatenvarchar(50)

    )

  • Well first off store dates as dates not as strings,

    So you would need to change AccessDate to DATETIME or add a column of the DATETIME data type.

    They look at creating a default

    CREATE TABLE DateColumnTable

    (

    DateColumn DATETIME DEFAULT GETDATE()

    )

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply