TBL COL NAME DATATYPE ALLOW NULL
Subscriber_ID int Unchecked
Subscriber_Initial varchar(5) Unchecked
Subscriber_Name varchar(50) Unchecked
Subscriber_Email varchar(50) Unchecked
Subscriber_Group varchar(20) Unchecked
Subscriber_Date datetime Unchecked
Subscriver_Active bit Unchecked
Subscriver_ActivateDate datetime Unchecked
Subscriver_DeactivateDate datetime Checked
Now When the user signed up, i need to check whether he’s already existed in the table.
If not, Create a new record.
If so, check whether the user is active.
If not, activate it. update the activate date.
If so, return he’s already signed up.
INSERT INTO
[ZCustom_SubscriberList]
(Subscriber_Initial,Subscriber_Name,Subscriber_Email,Subscriber_Group,Subscriber_Date)
select @initial,@name,@email,'A1',@subdate
WHERE NOT EXISTS (SELECT * FROM [ZCustom_SubscriberList] WHERE Subscriber_Email=@email)
This is my code and it is working fine without Active column. I am wondering how to add in the activate part.
Something like this should work: (Disclaimer: this is untested code, but you should get the general idea)