See with else part then you can get the point where it is missing if condition in your nested query
IF EXISTS(SELECT * FROM Framework.Service WHERE ID = 'B0ED76DD-F93B-4B64-8E87-654129E2A8AC' AND DeploymentID = 'D6726F6A-10A0-4917-AFD3-21949A62CD51')
begin
--check whether ma package is not installed
IF NOT EXISTS(SELECT * FROM Framework.Service WHERE ID = '764AE521-320E-4B90-A9F7-5C7614C5C28E' AND DeploymentID = '3015C5DB-DE04-4B73-89BF-AEDE95F3D9F8')
begin
if exists (select * from [Framework].[Object] where id = '8AC96BD2-9550-486B-804E-A40D0C57D6EC')
begin --go
Update Custom.Membership
set membershiptype = 'Unlimited/Ongoing' where Ongoing = 1
end
else begin
select 'else part of last nested if'
end
end
else begin
select 'else part of second nested if'
end
end
else begin
select 'else part of first nested if'
end