惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
G
Google Developers Blog
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
博客园 - 聂微东
V
Visual Studio Blog
博客园_首页
D
DataBreaches.Net
腾讯CDC
I
InfoQ
F
Fortinet All Blogs
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
月光博客
月光博客
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
C
Check Point Blog

博客园 - Seer Lin

自己开发的ERP系统,有需要的联系 MSCRM2016 取消邮箱强制SSL 不听话的下属辞职记 Windows 7下,巧让家用UPS也支持电脑自动关机 海蜘蛛去广告 [转]SQL2008链接服务器数据同步 asp.net 在IE8 导出excel时的问题 [转]mssql链接服务器 win2008 R2 64位系统下配置DCOM权限 [转]excel 操作类 在excel中,将 长*宽*高 这样的格式列,拆分成3列 将没有产品图片的产品设置为不在前台显示SQL实现 [转]在Reporting Services报表中引用FTP站点上的图片 mscrm js webservic 常用功能 mscrm4.0 判断当前用户角色_示例 mscrm 4.0 获取当前用户角色 mscrm4.0 获取当前登录的用户名 mscrm4.0 用js调用Webservice vs2010 js 代码折叠插件 MSCRM offline plugin开发注意事项
MSCRM 删除客户数据
Seer Lin · 2011-01-21 · via 博客园 - Seer Lin

代码


declare @i int=1
declare @tmpTable table(Id uniqueidentifier primary key)delete dbo.OpportunityExtensionBase
delete dbo.OpportunityProductExtensionBase
delete dbo.OpportunityProductBase
delete dbo.OpportunityCloseBase
delete dbo.OpportunityCompetitors
delete dbo.QuoteDetailExtensionBase
delete dbo.QuoteDetailBase
delete dbo.QuoteExtensionBase
delete dbo.QuoteBase
delete dbo.SalesOrderDetailExtensionBase
delete dbo.SalesOrderDetailBase
delete dbo.SalesOrderExtensionBase
delete dbo.SalesOrderBase
delete dbo.InvoiceDetailExtensionBase
delete dbo.InvoiceDetailBase
delete dbo.InvoiceExtensionBase
delete dbo.InvoiceBase
delete dbo.OpportunityBasedelete dbo.PhoneCallExtensionBase
delete dbo.PhoneCallBasedelete dbo.TaskExtensionBase
delete dbo.TaskBasedelete dbo.LetterExtensionBase
delete dbo.LetterBasedelete dbo.LeadProduct
delete dbo.LeadExtensionBasedelete dbo.LeadCompetitors
delete dbo.LeadAddressBase
delete dbo.LeadBasedelete dbo.FaxExtensionBase
delete dbo.FaxBasedelete dbo.EmailHashBase
delete dbo.EmailExtensionBase
delete dbo.EmailBasetruncate table dbo.CustomerAddressExtensionBase
--declare @i int=1,@id uniqueidentifier
--
declare @tmpTable table(Id uniqueidentifier)
set @i=1
while @i>0
begin    
    
insert into @tmpTable
    
select top 20000 CustomerAddressId from dbo.CustomerAddressBase
    
set @i=@@ROWCOUNT
    
delete from dbo.CustomerAddressBase where CustomerAddressId in(
        
select [Id] from @tmpTable
    )
    
    
delete @tmpTable
enddelete dbo.AppointmentExtensionBase
delete dbo.AppointmentBase--declare @i int=1,@id uniqueidentifier
--
declare @tmpTable table(Id uniqueidentifier)
set @i=1
while @i>0
begin    
    
insert into @tmpTable
    
select top 20000 ActivityId from dbo.AppointmentBase
    
set @i=@@ROWCOUNT
    
delete from dbo.AppointmentBase where ActivityId in(
        
select [Id] from @tmpTable
    )    
    
delete @tmpTable
enddelete dbo.BulkOperationLogBase
delete dbo.BulkOperationBasedelete dbo.ServiceAppointmentBasedelete dbo.CampaignActivityItemBase
delete dbo.CampaignActivityBase
delete dbo.CampaignActivityBasedelete dbo.ActivityPointerBase
delete dbo.ActivityPartyBasedelete dbo.ContactExtensionBase
--declare @i int=1,@id uniqueidentifier
--
declare @tmpTable table(Id uniqueidentifier)
set @i=1
while @i>0
begin    
    
insert into @tmpTable
    
select top 20000 ContactId from dbo.ContactBase
    
set @i=@@ROWCOUNT
    
delete from dbo.ContactBase where ContactId in(
        
select [Id] from @tmpTable
    )    
    
delete @tmpTable
enddelete dbo.AccountLeadstruncate table dbo.AccountExtensionBase
--declare @i int=1,@id uniqueidentifier
--
declare @tmpTable table(Id uniqueidentifier)
set @i=1
while @i>0
begin    
    
insert into @tmpTable
    
select top 20000 AccountId from dbo.AccountBase
    
set @i=@@ROWCOUNT
    
delete from dbo.AccountBase where AccountId in(
        
select [Id] from @tmpTable
    )    
    
delete @tmpTable
end