Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='ReleaseMay2025Week4'; 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 (select count(*) from System_Default where Default_Value in ('157', '188', '225', '268', '284', '315') and Default_Name = 'Main_Store_ID') > 0 begin if (select count(*) from Denomination where Single_Value = '6000.00') = 0 begin insert into Denomination(Description, Single_Value) values ('N$ 60''s', 6000.00) end end go alter table BuyshopGoldCalculatorLogs add BuyPrice decimal(18, 2) null default 0; go IF OBJECT_ID('spInsertBuyshopGoldCalculatorLog', 'p') IS NOT NULL BEGIN DROP PROCEDURE [dbo].[spInsertBuyshopGoldCalculatorLog]; END GO CREATE PROCEDURE [dbo].[spInsertBuyshopGoldCalculatorLog] @BuyshopTransactionId BIGINT, @ProductId BIGINT, @Description VARCHAR(200), @Weight DECIMAL(10,2), @Caret VARCHAR(20), @BuyerId BIGINT, @Overwitten BIT, @AuthorizerId BIGINT, @BuyshopTransLineId BIGINT, @BuyPrice DECIMAL(18,2) AS BEGIN SET NOCOUNT ON; BEGIN TRY BEGIN TRANSACTION; INSERT INTO BuyshopGoldCalculatorLogs(BuyshopTransactionId, ProductId, Description, Weight, Caret, BuyerId, Overwritten, AuthorizerId, BuyshopTransLineId, BuyPrice) VALUES (@BuyshopTransactionId, @ProductId, @Description, @Weight, @Caret, @BuyerId, @Overwitten, @AuthorizerId, @BuyshopTransLineId, @BuyPrice) COMMIT TRANSACTION; END TRY BEGIN CATCH -- Rollback the transaction on error IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION; -- Log the error DECLARE @ErrorMessage NVARCHAR(4000), @ErrorSeverity INT, @ErrorState INT; SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); -- Rethrow the error RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState); END CATCH; END GO if((select count(0) from System_Default where Default_Name = 'isjv' and Default_Value = '1')=1) begin update SystemSetting set SettingValueBit = 1 where SettingKey in ('CcwLayby','CcwLaybySelectorSkip'); end; Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'ReleaseMay2025Week4'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO