1 ETQ000 ================================================== 1 ETQ399 Executing SQL script '..\var\MSSDROPSHD.TSQL'. 2 ETQ399 Connecting to database 'mss'. 4 ETQ010 Date & Time: 20200722190606 3 ETQ398 SQL: set nocount on 3 ETQ398 SQL: if(exists( select * from sys.objects where name = 'upg_dropcmds' and 3 ETQ398XSQL: object_id = object_id(user_name() + '.' + name, 'U') )) drop table 3 ETQ398XSQL: [upg_dropcmds] create table upg_dropcmds (otype char(2) primary key, 3 ETQ398XSQL: ocmd varchar(100)) 3 ETQ398 SQL: if(exists( select * from sys.objects where name = 'upg_dbss' and 3 ETQ398XSQL: object_id = object_id(user_name() + '.' + name, 'U') )) drop table 3 ETQ398XSQL: [upg_dbss] create table upg_dbss (dname sysname) 3 ETQ398 SQL: declare @cmd varchar(250) declare @dbname sysname insert upg_dropcmds 3 ETQ398XSQL: values ('U', 'drop table ') insert upg_dropcmds values ('V', 3 ETQ398XSQL: 'drop view ') insert upg_dropcmds values ('P', 'drop procedure ') 3 ETQ398XSQL: insert upg_dropcmds values ('IF', 'drop function ') insert 3 ETQ398XSQL: upg_dropcmds values ('TF', 'drop function ') insert upg_dropcmds 3 ETQ398XSQL: values ('FN', 'drop function ') insert upg_dropcmds values ('D', 3 ETQ398XSQL: 'drop default ') declare udbs cursor for select name from 3 ETQ398XSQL: master.sys.databases where name <> 'master' and name <> 'EHI' and 3 ETQ398XSQL: state = 0 and replica_id IS NULL open udbs fetch next from udbs into 3 ETQ398XSQL: @dbname while @@fetch_status = 0 begin select @cmd = 3 ETQ398XSQL: 'if(exists(select name from ['+@dbname+'].sys.database_principals where name = ''ehi_shd'' )) insert upg_dbss values('''+@dbname+''')' 3 ETQ398XSQL: exec (@cmd) fetch next from udbs into @dbname end close udbs 3 ETQ398XSQL: deallocate udbs 3 ETQ398 SQL: use EHI declare @cmd varchar(250) declare @objname sysname declare 3 ETQ398XSQL: @objtype char(2) if(exists(select name from 3 ETQ398XSQL: master.sys.server_principals where name = 'ehi_shd')) begin use msdb 3 ETQ398XSQL: execute as login = suser_sname(0x01) exec sp_manage_jobs_by_login 3 ETQ398XSQL: @action = N'DELETE', @current_owner_login_name = N'ehi_shd' REVERT; 3 ETQ398XSQL: use EHI declare objnames cursor for select name, type from 3 ETQ398XSQL: sys.objects where object_id = object_id('ehi_shd' + '.' + name) and 3 ETQ398XSQL: type <> 'PK' and name != 'upg_dropcmds' order by type desc open 3 ETQ398XSQL: objnames fetch next from objnames into @objname, @objtype while 3 ETQ398XSQL: @@fetch_status != -1 begin if(@@fetch_status = 0) begin select 3 ETQ398XSQL: @cmd = '' select @cmd = ocmd from upg_dropcmds where otype = 3 ETQ398XSQL: @objtype if(len(@cmd) > 0) begin select @cmd = @cmd + 3 ETQ398XSQL: '[ehi_shd].[' + @objname + ']' print 'executing ' + @cmd exec 3 ETQ398XSQL: (@cmd) end else print 'Unable to drop objects of type ' + 3 ETQ398XSQL: @objtype end fetch next from objnames into @objname, @objtype end 3 ETQ398XSQL: close objnames deallocate objnames use EHI if(exists(select * from 3 ETQ398XSQL: sys.schemas where name = 'ehi_shd')) BEGIN DROP SCHEMA ehi_shd END 3 ETQ398XSQL: if(exists(select name from sys.database_principals where name = 3 ETQ398XSQL: 'ehi_shd')) begin DROP USER ehi_shd end if(not exists(select 3 ETQ398XSQL: dname from [upg_dbss])) begin use master if(exists(select * from 3 ETQ398XSQL: sys.schemas where name = 'ehi_shd')) BEGIN DROP SCHEMA ehi_shd 3 ETQ398XSQL: END if(exists(select name from sys.database_principals where name = 3 ETQ398XSQL: 'ehi_shd')) begin DROP USER ehi_shd end DROP LOGIN ehi_shd 3 ETQ398XSQL: end else begin RAISERROR 3 ETQ398XSQL: ('Important information from your SAP team: User ehi_shd has access to dbs other then EHI, so the login can 3 ETQ398XSQL: not be dropped by the upgrade! (Are you running some upgrades in parallel?) Please drop the user ehi_shd in all other databa 3 ETQ398XSQL: ses', 18, 1); end end use EHI drop table [upg_dropcmds] drop table 3 ETQ398XSQL: [upg_dbss] set nocount off 1 ETQ000 ================================================== 4 ETQ010 Date & Time: 20200722190645 1 ETQ003 exit code: "0"