Table structure:
ID int
status varchar (10)
DATE_CREATED datetime
DATE_CLOSED datetime
Stored procedure for filling DATE_CREATED:
CREATE PROCEDURE [dbo].[...]
@ID INT,
@STATUS VARCHAR(10) = 'Open',
@DATE_CREATED DATETIME = NULL
AS
SET NOCOUNT ON
UPDATE table
SET STATUS = @STATUS,
DATE_CREATED = COALESCE(@DATE_CREATED, GETDATE())
FROM table
From that point the column DATE_CLOSED is NULL. I wanted to automatically fill the column with the date of DATE_CREATED column but with the time of 10pm, and it should be filled by 10pm automatically and also the status filled to 'closed'.