SLAM_query_bulk
Overview
This command uses the Salesforce Bulk v1 API to query the object. If an sObject name is provided instead of a SOQL query, all fields and records will be returned for that object.
Performance tip: Some Salesforce objects support PK Chunking, which parallelizes the query operation on the Salesforce server. This can lead to dramatic time reductions in query operations. To enable PK Chunking, provide a value for @pkchunksize (typical values are 100,000 up to a max of 250,000). Refer to Salesforce Bulk Documentation for more details including the list of objects that are supported. Salesforce supports PK Chunking a SOQL query that already has filter criteria.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
@query | NVARCHAR | Required | sObject name or SOQL query string. When just an sObject name is passed, queries all records & fields |
@table | VARCHAR | Required | Target SQL table name for results |
@pkchunksize | INT | NULL | Enables PK chunking for large datasets when specified. If NULL, no chunking. Typical values: 100,000 to max of 250,000 |
@queryall | BIT | 0 | When 1, includes deleted/archived records |
@exists_action | VARCHAR(20) | SLAM_Settings.default_exists_action | Controls the behavior when the destination table name, specified by @table is already used. If NULL, uses the value from SLAM_Settings.default_exists_action (defaulted to 'drop' during initial setup).Valid options:
|
Usage Examples
Retrieve all records and fields from the Account object:
EXEC dbo.SLAM_query_bulk
@query = 'Account',
@table = 'Account_query';
Retrieve a filtered set of records from the Account object:
EXEC dbo.SLAM_query_bulk
@query = 'SELECT * FROM Account WHERE CreatedDate > 2025-08-01T01:02:03Z',
@table = 'Account_query';
Retrieve deleted and archived records with PK Chunking:
EXEC dbo.SLAM_query_bulk
@query = 'SELECT Id, IsDeleted, Subject, Status, OwnerId FROM Task',
@table = 'Task_queryall',
@pkchunksize = 100000,
@queryall = 1;