Yes, here you are trying. When new subscriber data is entered, the registration date is the current date, the expiring date is 30 days after the current date. In your sql statement, you do not need to mention these two columns (REGISTER_DT, EXPIRE_DT), these two will be updated automatically when you insert the statement.
Based on the following table structure, your insert statement should be
INSERT INTO SAMPLE (SUBSCRIBER_NM) VALUES ('John');
- table creation instruction
CREATE TABLE [dbo].[SAMPLE]( [SUBSCRIBER_ID] [int] IDENTITY(1,1) NOT NULL, [SUBSCRIBER_NM] [nvarchar](50) NOT NULL, [REGISTER_DT] [datetime] NOT NULL CONSTRAINT [DF_SAMPLE_REGISTER_DT] DEFAULT (getdate()), [EXPIRE_DT] [datetime] NOT NULL CONSTRAINT [DF_SAMPLE_EXPIRE_DT] DEFAULT (dateadd(day,(30),getdate())), CONSTRAINT [PK_SAMPLE] PRIMARY KEY CLUSTERED ( [SUBSCRIBER_ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
source share