Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='ReleaseAug2024Week4'; if @@ROWCOUNT!=0 BEGIN RAISERROR('THIS SCRIPT HAS ALREADY BEEN RUN ON THIS SERVER, CANNOT CONTINUE, PLEASE CONTACT DEV',11,1); RETURN; END GO IF COL_LENGTH('Product', 'SerialRequired') IS NULL BEGIN ALTER TABLE Product ADD SerialRequired BIT DEFAULT(0); END GO /*Deactivate all current questions*/ UPDATE ReturnQuestion SET Active = 0 WHERE QuestionId <= 15 /*Add new questions*/ IF (SELECT COUNT(1) FROM ReturnQuestion WHERE Description = 'Is the product complete with all accessories and the box?') = 0 BEGIN INSERT INTO ReturnQuestion (Description, IsYes, IsNo, Active) VALUES ('Does the customer have their CashPOS till slip with the correct item and serial number (if applicable) and dated within 6 months from today?', 1, 0, 1), ('Are there any obvious signs of abuse, impact or alterations like a cut plug that you can see with a naked eye?', 0, 1, 1), ('Is the product complete with all accessories and the box?', 1, 0, 1) END GO IF (OBJECT_ID('CheckBuyshopSellerFicAnswers', 'P')) IS NOT NULL BEGIN DROP PROCEDURE CheckBuyshopSellerFicAnswers END GO CREATE PROCEDURE CheckBuyshopSellerFicAnswers -- Add the parameters for the stored procedure here @sellerId bigint AS BEGIN SET NOCOUNT ON; SELECT TOP(1) COUNT(1) FROM Buyshop_FIC_Seller_Info WHERE Seller_ID = @sellerId AND Created > DATEADD(DAY, -365, GETDATE()) END GO Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'ReleaseAug2024Week4'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO