hi i have this stored procedure. I have written begin tran command. after that i have also written rollback tran and commit tran in the end. still when i run it, SS says that begin tran or commit tran wasnt found !! but those stmts are already there. Pls help --find previously alotted_qty. It will be used later on to find how much qty was updated declare @prev_qty as int, @prev_brand as varchar(50), @prev_model_no as varchar(50) set @prev_qty = (select qty from telephone_alottment where sr_id = @sr_id) set @prev_brand = (select model_brand from telephone_alottment where sr_id = @sr_id) set @prev_model_no = (select model_number from telephone_alottment where sr_id = @sr_id) IF (@qty - @prev_qty)<= (select sum(available_qty) from mobile_master where model_number = @model_number and model_brand = @model_brand) BEGIN IF datediff(dd,(select min(date_of_purchase) from mobile_master where model_brand = @model_brand and model_number = @model_number),@alottment_date) < 0 BEGIN set @msg = 'Alottment date cannot be earlier than Purchase Date which is ' + convert(varchar,(select min(date_of_purchase) from mobile_master where model_brand = @model_brand and model_number = @model_number),103) select @msg END ELSE BEGIN --#################### ADJUST QUANTITY IN MOBILE_MASTER ONLY IF @PREV_ALOTTED_QTY IS DIFFERENT THAN @QTY ################################--here it means that brand or model no was changed, so we have to return quantity to previous brand or model. then we--call the proc again to set new value begin tran update telephone_alottment set alottment_group = @alottment_group, alotted_to = @alotted_to, model_number = @model_number, model_brand = @model_brand, modify_date = getdate(), alottment_date = @alottment_date, modified_by = @modified_by, approved_by = @approved_by, qty = @qty where sr_id = @sr_id IF (@prev_brand <> @model_brand) OR (@prev_model_no <> @model_number) BEGIN select 'inside this shit' exec adjustMobileQtyOnUpdate @prev_qty,'Increase',@prev_model_no,@prev_brand,@alottment_date,@alottment_group,@alotted_to,@msg OUTPUT, @status OUTPUT exec adjustMobileQtyOnUpdate @qty,'Decrease',@model_number,@model_brand,@alottment_date,@alottment_group,@alotted_to,@msg OUTPUT, @status OUTPUT IF @status = 0 BEGIN select @msg rollback tran END END ELSE BEGIN IF @qty <> @prev_qty BEGIN IF @prev_qty > @qty BEGIN set @qty = @prev_qty - @qty exec adjustMobileQtyOnUpdate @qty,'Increase',@model_number,@model_brand,@alottment_date,@alottment_group,@alotted_to,@msg OUTPUT, @status OUTPUT END ELSE BEGIN set @qty = @qty - @prev_qty exec adjustMobileQtyOnUpdate @qty,'Decrease',@model_number,@model_brand,@alottment_date,@alottment_group,@alotted_to,@msg OUTPUT, @status OUTPUT END IF @status = 0 BEGIN select @msg return END END END commit tran END END