Insert prev datetime in insertstatement

  • CREATE TABLE [dbo].[dt](
        [dtVal] [datetime] NOT NULL,
        [dtVal2] [datetime] NOT NULL,
    PRIMARY KEY CLUSTERED
    (
        [dtVal] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]

    I insert a date in the table but I want to have the prev value that I insert in dtVal2

    Insert into dt values (GETPREV-dtval2 as dtval), getdate() as dtVal2)

  • Srry put the wrong group

  • GG_BI_GG - Friday, July 27, 2018 8:40 AM

    Srry put the wrong group

    And what determines what is the previous value?  Some sample data and expected results may help.

  • Double post, put answers here.

Viewing 4 posts - 1 through 3 (of 3 total)

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