View Categories

Schema Check

4 min read

Salesforce Load (ss_Loader) Schema Check #

Purpose #

ss_SchemaCheck validates a SQL load table for use with ss_Loader against Salesforce field and object metadata before executing a load.

The output is a column-level report highlighting:

  • mapping issues
  • permission constraints
  • datatype risks
  • optional data content issues

Parameters #

ParameterPurpose
@EnvSQL Sales Environment Name, see Setup
@TableNameSource load table (e.g. Account_demo_Insert)
@OperationDefines validation behaviour based on Salesforce API operation eg “Insert”
@PermittedSuffixesColumns with these suffixes are intentionally ignoredDeployed with:@PermittedSuffixes nvarchar(4000) = N’_Orig,_Info’Example:Name_Orig Amount_Info
@PermittedColumnNamesExplicitly ignored columns (e.g. system/helper fields)Deployed with:@PermittedColumnNames nvarchar(4000) = N’SSId’Example:SSId
@CheckDataContentsControls row-level validation:Deployed with:@CheckDataContents bit = 1
@CheckReferencePrefixValidates Salesforce ID prefixesValidates the first 3 and enforces case-sensitive comparison for Salesforce ID keyprefix validation to ensure accurate detection of mismatched references.Deployed with:@CheckReferencePrefix bit = 0
@UpsertRequireInsertFieldsControls UPSERT strictness:Deployed with:@UpsertRequireInsertFields bit = 0
@Special1Future use, not currently used
@Special2Future use, not currently used

Usage Example #

exec dbo.ss_SchemaCheck
@Env = 'UAT'
,@TableName = 'Account_demo_Insert'
,@Operation = 'Insert'
,@PermittedSuffixes = '_Orig,_Info'
,@PermittedColumnNames = 'SSId'
,@CheckDataContents = 1
,@CheckReferencePrefix = 0
,@UpsertRequireInsertFields = 0

Key parameters in detail #

@Env #

Your pre-configured Environment (see Configuration Manager)

@TableName #

Source load table (e.g. Account_demo_Insert)

@Operation #

Defines validation behaviour based on Salesforce API operation.

Supported values:

Insert operations #

  • Insert
  • BulkAPIv1Insert
  • BulkAPIv2Insert

Validates:

  • Createable fields
  • Required fields present

Update operations #

  • Update
  • BulkAPIv1Update
  • BulkAPIv2Update

Validates:

  • Updateable fields only
  • Required fields NOT enforced

Upsert operations #

  • Upsert
  • BulkAPIv1Upsert
  • BulkAPIv2Upsert

Hybrid behaviour:

Controlled by:

  • @UpsertRequireInsertFields
SettingBehaviour
1Validate like INSERT (strict)
0Validate like UPDATE (relaxed)

Delete operations #

  • Delete
  • BulkAPIv1Delete
  • BulkAPIv2Delete

Undelete #

  • Undelete

Hard delete #

  • BulkAPIv1Harddelete
  • BulkAPIv2Harddelete

Delete / Undelete / HardDelete behaviour #

For all delete-type operations:

Only these columns are required:

  • Id
  • Error

All other columns are:

  • ignored
  • marked as Ignored for Action

@PermittedSuffixes #

Columns with these suffixes are intentionally ignored

Example:

Name_Orig Amount_Info

@PermittedColumnNames #

Explicitly ignored columns (e.g. system/helper fields)

Example:

SSId

@CheckDataContents #

Controls row-level validation:

ValueBehaviour
1Run data checks (length, numeric, IDs, etc.)
0Skip content validation

@CheckReferencePrefix #

Validates Salesforce ID prefixes

Validates the first 3 and enforces case-sensitive comparison for Salesforce ID keyprefix validation to ensure accurate detection of mismatched references.

@UpsertRequireInsertFields #

Controls UPSERT strictness:

ValueBehaviour
1Treat UPSERT like INSERT (safer option)
0Treat UPSERT like UPDATE (looser option)

How to read the output #

Each row = one source column

OverallStatus (main result) #

StatusMeaning
OKSafe
PermittedIgnored by design
Potential IssueRisk
Actual IssueProblem
Ignored for ActionNot relevant
n/aNot Applicable / Not relevant

Validation layers #

ExistenceStatus #

Does the column exist in Salesforce?

PermissionStatus #

Can the field be written to?

DataTypeStatus #

Is the SQL datatype structurally compatible?

Does NOT validate actual values

ContentStatus #

Result of actual data checks

StatusMeaning
CheckedPassed implemented checks
Not CheckedSkipped
Actual IssueInvalid data found
PermittedIgnored
Ignored for ActionNot relevant
n/aNot Applicable / Not relevant

Detail column #

Explains exactly what was detected and is a useful debugging aid

[Datatype] SQL text type is acceptable base type
[Datatype] Text column length is not 18 characters
[Content] Invalid Salesforce Id detected
[Existence] Column suffix _Info is permitted
[Synthetic] Required field missing

Mandatory load columns #

Id – must be 18-char text

Error – must be nvarchar(255)

Permitted columns #

Ignored safely:

suffix-based (_Orig, _Info)

explicit names (SSId)

Synthetic rows #

Example:

Missing Required Target Field

Salesforce requires this field

Source table does not include it

What this tool does NOT validate #

The procedure does NOT validate:

  • picklist values
  • reference record existence
  • Salesforce validation rules
  • triggers / flows
  • business logic

ContentStatus = Checked means:

“No issues found in the checks implemented here” but this is not a guaranteed load success.

Workflow #

  1. Run ss_SchemaCheck
  2. Filter OverallStatus <> OK
  3. Fix:
    • Actual Issues first
    • then review Potential Issues
  4. Ignore Permitted / Ignored for Action
  5. Proceed with load

Note #

  • Use @CheckDataContents = 1 for full validation
  • Use strict UPSERT mode during testing
  • Use suffixes for helper columns
  • Always read the Detail column

Summary #

This procedure is a:

Pre-load validation tool for Salesforce data loads

It helps you:

  • detect schema mismatches
  • reduce load failures
  • understand data risks
  • safely manage helper/system columns

When debugging #

Check in order:

  1. OverallStatus
  2. Detail
  3. DataTypeStatus
  4. ContentStatus
  5. BadRowCount

Output Report Definition #

You provided table name will be reported as a table with the same name and “_Report” suffixed. This is outputted to the screen on execution and preserved in this created table.

ColumnPurpose
OverallStatusFinal consolidated result for the column
Values:OK = safePermitted = intentionally ignoredPotential Issue = riskActual Issue = problemIgnored for Action = not relevant (e.g. delete)n/a = Not ApplicableLogic:
Derived from:ExistenceStatusPermissionStatusDataTypeStatusContentStatusThis is the primary column for filtering and decision-making
ExistenceStatusDoes the column map to Salesforce?Values:OK = exists in SF metadataPermitted = ignored via suffix or explicit ruleActual Issue = not found in SFIgnored for Action = delete-type loadsn/a = Not Applicable
PermissionStatusCan the field be written to in Salesforce?Values:OKActual Issue = not Createable/UpdateablePermittedNot Applicable = control columns (Id, Error)Ignored for Actionn/a = Not Applicable
DataTypeStatusStructural compatibility between SQL type and SF typeValues:OKPotential Issue = e.g. precision/length mismatchActual Issue = incompatible typesPermittedIgnored for ActionDoes NOT validate actual values
ContentStatusResult of actual data checks (optional)Values:Checked (or OK depending on your naming)Not CheckedActual IssuePermittedIgnored for ActionOnly reflects checks implemented in this procedure, not full SF validation
DetailHuman-readable explanation of findingsFormat:Multi-part, pipe-delimitedTagged with categories:Examples:[Datatype] SQL text type is acceptable base type
[Content] Invalid Salesforce Id detected
[Existence] Column suffix _Info is permitted
[Synthetic] Required field missingPrimary debugging column
BadRowCountNumber of rows failing a content checkNULL if no failure or check not applicablePopulated only when issues found
SourceColumnNameActual column name in load table
RowCategoryClassifies row typeValues:Mandatory Load Column → Id, ErrorSource Column → normal columnsMissing Required Target Field → synthetic rows
BaseColumnNameColumn name after removing suffixExample:Name_Info = NameUsed for:mapping to Salesforce field
SourceDataTypeSQL datatype (e.g. nvarchar, int, nchar)
SourceMaxLengthBytesRaw SQL Server storage size
SourceMaxLengthCharsLogical character length (important for Unicode)
SourcePrecision / SourceScaleFor numeric types
SourceNullableWhether column allows NULL
SourceIdentityIdentity column flag
SourceComputedComputed column flag
SFFieldNameAPI name in Salesforce
SFFieldLabelUser-friendly label
SFDataTypeSalesforce datatype
(e.g. string, reference, currency, boolean)
SFLength / SFByteLengthMax field size
SFPrecision / SFScaleNumeric constraints
SFCreateable / SFUpdateablePermissions from metadata
SFUniqueField must be unique
SFNillableAllows NULL
SFExternalIdExternal ID flag
SFNameFieldIs the object’s Name field
SFReferenceToTarget object for reference fieldsExample:Account
User
SuffixMatchedMatched suffix from:@PermittedSuffixes = ‘_Orig,_Info’
IsPermittedByNameExplicit override flagExample:@PermittedColumnNames = ‘SSId’
OrdinalPositionColumn order in source tableSpecial cases:very large values (e.g. 300000001) = synthetic rows

Run it. Fix issues. Load with confidence.

Leave a comment

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