View Categories

Database Enabling

3 min read

ss_EnableDatabase.sql #

Provided alongside the SQLSalesInstaller.exe, the “enabling” script ss_EnableDatabase.sql will fully deploy the required SQL Server components (stored procedures and functions).

ss_EnableDatabase.sql is installed to the exe install location – typically to the default C:\Program Files\SQLSales, hence: C:\Program Files\SQLSales\ss_EnableDatabase.sql

Open and compile to your chosen database, to “enable” that database for use with SQL Sales.

Note, SQL-Sales requires that xp_cmdshell is enabled on your SQL Server. If it is not, the enabling script will identify that and provide a suggested script to run, to alter your system configuration settings.

The following are deployed to your target (schema) and database by running the enabling script:

ObjectTypePurpose
ss_AdminStored ProcedurePrimarily to control the Daemon from your SSMS client
ss_DeltaStored ProcedureDelta Replication of Salesforce data
ss_DeltaAllStored ProcedureDelta Replication of Salesforce data (all objects)
ss_HandlerStored ProcedureGeneric process used by most stored procedure calls to interact with the Handler application
ss_LoaderStored ProcedureAllows bulk loads to Salesforce via the SOAP and Bulk APIs (Version 1 & 2)
ss_LoaderChecksStored ProcedureSupports ss_Loader
ss_LoggerStored ProcedureSupports Logging
ss_MetaFieldStored ProcedureReturns Field metadata
ss_MetaObjectStored ProcedureReturns Object metadata
ss_MetaPickStored ProcedureReturns Picklist metadata
ss_MetaFieldXStored ProcedureReturns extended Salesforce field metadata, including descriptions, formulas, relationships, security settings, and compliance attributes, providing a comprehensive view of field design, behaviour, and governance.
ss_MetaPickXStored ProcedureReturns metadata-enriched Picklist values, including field details, value set source, controlling field, and active status, per Object or for a specified Object.
ss_MetaPickDepStored ProcedureReturns dependent Picklist mappings by Record Type, including controlling field hierarchy, controlling values, dependent values, and internal dependency indexes, per Object or for a specified Object.
ss_MetaPickRTStored ProcedureReturns Picklist values by Record Type, including dependency hierarchy, controlling field relationships, and index mappings, per Object or for a specified Object.
ss_MetaRegion Stored ProcedureExtracts the organisation’s configured State and Country/Territory picklists using the Salesforce Metadata API, returning the full definition of countries and states, including inactive values, visibility settings, default flags, and the hierarchical relationship between countries and their associated states.
ss_MetaLayoutStored ProcedureReturns Page Layout structure per Object, including sections, columns, fields, and display behaviour, for all Objects or a specified Object.
ss_MetaLayoutActionStored ProcedureExtracts Salesforce page layout actions (buttons and quick actions), including their placement, grouping, and visibility, enabling analysis of user interaction points across layouts.
ss_MetaLayoutRelatedListStored ProcedureReturns Page Layout Related List configuration per Object, including related lists, fields, and display settings, for all Objects or a specified Object.
ss_MetaVRStored ProcedureReturns Validation Rules per Object, including rule logic, error messages, and active status, for all Objects or a specified Object.
ss_ObjectLogStored ProcedureSupports Logging
ss_PullChecksStored ProcedureSupports ss_Replica & ss_Delta
ss_ReplicaStored ProcedureFull Replication of Salesforce data
ss_ReplicaAllStored ProcedureFull Replication of Salesforce data (all objects)
ss_UserInfoStored ProcedureMiscellaneous user information for a given Environment
ss_18FunctionHelper function to generate the full 18 character case insensitive Salesforce Id from a 15 character case sensitive Id.
ss_AutoReplicaTableControls if a given Object is automatically fully replicated when calling ss_DeltaAll
ss_BulkAPILogTableLog table used by ss_Loader and the Bulk API
ss_LogTableLog table for all SQL Sales Delta and Full replications for a given Salesforce object
ss_Log_WorkingTableFiner logging detail to ss_Log
ss_ObjectExclusionTableControl which objects are excluded from ss_ReplicaAll and ss_DeltaAll
ss_ObjectInclusionTableControl which objects are included from ss_ReplicaAll and ss_DeltaAll
ss_SysFieldTableOutput from ss_MetaField
ss_SysObjectTableOutput from ss_MetaObject
ss_SysPicklistTableOutput from ss_MetaPicklist
ss_SystemTableContains the deployed SQL Sales Version
ss_LoaderDefinitionFunctionSupports ss_Loader
ss_SchemaDefinitionFunctionSupports ss_Replica & ss_Delta

Full Schema isolation support #

SQL Sales can run in separate schema on the same databases, which can be helpful for certain use cases or where for example you can only operate in one database and need to have different sandboxes replicated to different schemas, even if necessary having Production replication in their own “prod” schema (although generally speaking as best practise we would advise to physically separate a Production replication to its own dedicated database and ideally to its own SQL Server), that said we recognise some customers have to operate within very restricted SQL environments, which is why full schema isolation can be a real benefit.

Setup #

When enabling a given database, simply change the highlighted code block, specifying your required schema (unless the default dbo schema is required in which case do nothing). Now execute the script.

Working with schemas #

As with standard SQL Server, you do not need to specify the dbo schema when calling stored procedures or selecting from tables, if that is the schema you specified on your given installation (which is the usual default), hence using ss_Replica as an example:

exec ss_Replica 'DEMO', 'Account'
select * from Account

you can, if you prefer also run as

exec dbo.ss_Replica 'DEMO', 'Account'
select * from dbo.Account

Let’s say you have enabled with schema “uat” (for a User Acceptance Testing sandbox) and a second schema called “dev”(for a Development sandbox), you can run the below:

exec uat.ss_Replica 'UAT_SBOX', 'Account'
exec dev.ss_Replica 'DEV_SBOX', 'Account'

and thereby create physically separate replicas in tables:

uat.Account
dev.Account

select * from uat.Account
select * from dev.Account

Leave a Reply

Your email address will not be published. Required fields are marked *