back to top

A Script to Clear Out a SalesLogix SQL Database

There may be a time that you want to upload a database but would prefer not to share all of your data.  This script will leave all of the SalesLogix customizations intact but will remove all but 500 accounts.  There is a section at the end of this script where you can add your custom tables.  I have seen this script run for more then 2 hours so plan to wait quite a while.


This script is designed for SalesLogix prior to version 7.2.2 – proceed at your own risk.


–Custom Tables to be cleared need to be added at the bottom of the script


–********************************************************************************


–**—*** WARNING THIS QUERY CAN TAKE A LONG TIME TO RUN ***—***


–**—*** WARNING THIS QUERY IS NOT SLX SYNC AWARE ***—***


–********************************************************************************


–********************************************************************************


–**This query is what is used to limit what accounts will be kept on the DB.


–**All tables will drill down from this query.


–**To modify, put your condition(s) in the nested select statement in place of


–**(select top 500 accountid from account).


–********************************************************************************


–********************************************************************************


delete from account where accountid not in (select top 500 accountid from account)


Go


–********************************************************************************


–********************************************************************************


delete from contact where accountid not in (select accountid from account)


Go


delete from opportunity where accountid not in (select accountid from account)


Go


delete from address where addressid not in (select addressid from address where


entityid in (select accountid from account) or


entityid in (select contactid from contact) or


entityid in (select userid from userinfo) or

addressid in (select addressid from branchoptions))

Go

delete from history where historyid not in(select historyid from history where

accountid in (select accountid from account) or


contactid in (select contactid from contact) or


opportunityid in (select opportunityid from contact))


Go


delete from activity where activityid not in(select activityid from activity where


accountid in (select accountid from account) or


contactid in (select contactid from contact) or


opportunityid in (select opportunityid from contact))


Go


Delete from user_activity where activityid not in (select activityid from activity)


Go


Delete from accountsummary where accountid not in (select accountid from account)


Go


Delete from accountproduct where accountid not in (select accountid from account)


Go


Delete from ACT_Userdef where contactid not in (select contactid from contact)


Go


Delete from association where associationid not in (select associationid from association where


fromid in (select accountid from account) and


toid in (select accountid from account))


Go


Delete from attachment where attachid not in(select attachid from attachment where


accountid in (select accountid from account) or


contactid in (select contactid from contact) or


opportunityid in (select opportunityid from contact))


Go


Delete from campaigncontact where contactid not in (select contactid from contact)


Go


Delete from competitor where accountid not in (select accountid from account)


Go


Delete from competitor_contact where contactid not in (select contactid from contact)


Go


Delete from competitor_details where competitorid not in (select competitorid from competitor)


Go


Delete from competitorcustomer where competitorid not in (select competitorid from competitor)


Go


Delete from competitorproduct where competitorid not in (select competitorid from competitor)


Go


Delete from contact_leadsource where contactid not in (select contactid from contact)


Go


Delete from contactresponse where contactid not in (select contactid from contact)


Go


Delete from contract where accountid not in (select accountid from account)


Go


Delete from contractincident where contractid not in (select contractid from contract)


Go


Delete from contractitem where contractid not in (select contractid from contract)


Go

Delete from GM_Profile where gm_profileid not in (select gm_profileid from gm_profile where

accountid in (Select accountid from account) or


contactid in (select contactid from contact))


Go


Delete from litrequest where contactid not in (select contactid from contact)


Go


Delete litrequestitem where litreqid not in (select litreqid from litrequest)


Go


Delete from opportunity_campaign where opportunityid not in (select opportunityid from opportunity)


Go


Delete from opportunity_contact where opportunityid not in (select opportunityid from opportunity)


Go


Delete from opportunity_product where opportunityid not in (select opportunityid from opportunity)


Go


Delete from opportunity_salesstep where opportunityid not in (select opportunityid from opportunity)


Go


Delete from opportunity_user where opportunityid not in (select opportunityid from opportunity)


Go


Delete from resourceschedule where activityid not in (select activityid from activity)


Go


Delete from RMA where accountid not in (select accountid from account)


Go


Delete from rmareceivedproduct where rmaid not in (select rmaid from rma)


Go


Delete from rmashippedproduct where rmaid not in (select rmaid from rma)


Go


Delete from ticket where accountid not in (select accountid from account)


Go


Delete from ticketaccountproduct where ticketid not in (select ticketid from ticket)


Go


Delete from ticketactivity where ticketid not in (select ticketid from ticket)


Go


Delete from ticketactivityitem where ticketactivityid not in (select ticketid from ticket)


Go


Delete from tickethistory where ticketid not in (select ticketid from ticket)


Go


Delete from ticketproblem where ticketid not in (select ticketid from ticket)


Go


Delete from ticketsolution where ticketid not in (select ticketid from ticket)


Go


 


 


–Custom Tables


Delete from account2 where accountid not in (select accountid from account)


Go


Delete from contact2 where contactid not in (select contactid from contact)


Go


Delete from contactextension where contactid not in (select contactid from contact)


Go


Print “All Finished, please run a full Database Mainteneance Rountine to Shrink DB”

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos