Search Chirayu Software Solutions Blog

Friday, April 19, 2019

Delete all data of particular MiniadminUsername

 
CREATE TABLE [dbo].[MiniadminLoginMappingBackup](
 [miniadminUsername] [varchar](20) NOT NULL,
 [LoginId] [varchar](20) NOT NULL,
 CONSTRAINT [PK_MiniadminLoginMappingBackup] PRIMARY KEY CLUSTERED
(
 [miniadminUsername] ASC,
 [LoginId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

delete from [MiniadminLoginMappingBackup]
insert into [MiniadminLoginMappingBackup] select * from MiniadminLoginMapping

delete from [tblOrdersBook] where ordClientCode in ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from [tblTrades] where trdClientCode in ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from [DeletedTrades] where trdClientCode in ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from [DeletedTrades] where trdClientCode in ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from tblClientLimit where clClientCode in  ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from tblClientLimitLotWise where cllClientCode in  ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from UserMargin where ClientCode in  ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from tblLedger where lrClientCode  in ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
 
  delete from MobileNotificationMaster where MobileUsername in ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from MobileLogin where Username in ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  
  delete from UserPortfolio where UserName in  ( select clientcode from miniadminclientmapping where miniadminUsername = 'mandev')
  delete from MiniadminLoginMapping where miniadminUsername = 'mandev'
  delete from MiniadminClientMapping where miniadminUsername = 'mandev'
  delete from tblLogin where Username in ( select loginid from MiniadminLoginMappingBackup where miniadminUsername = 'mandev')
 
  delete from tblClientMaster where cmClientCode in ( select loginid from MiniadminLoginMappingBackup where miniadminUsername = 'mandev')

No comments: