SLAM_query
Overview
This generalized query method provides access to all three APIs and file downloading through a single procedure. It delegates to the appropriate query procedure based on the @api parameter, making it a convenient choice when the API selection needs to be dynamic. @batch_size is only relevant to SOAP API and @pkchunksize is only relevant to Bulk v1 API.
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 |
@api | NVARCHAR | Required | API to use ('bulk', 'bulkv2', or 'soap') |
@pkchunksize | INT | NULL | Enable PK chunking (Bulk v1 API only). If NULL, PK chunking is disabled |
@batch_size | INT | 2000 | Number of records per batch (SOAP API only) |
@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
Query using Bulk v1 API with PK Chunking:
EXEC dbo.SLAM_query
@query = 'Account',
@table = 'Account_query',
@api = 'bulk',
@pkchunksize = 100000
Query using SOAP API with custom batch size:
EXEC dbo.SLAM_query
@query = 'SELECT Id, Name, Email, Account.Name FROM Contact WHERE CreatedDate = TODAY',
@table = 'Contact_query',
@api = 'soap',
@batch_size = 1500
Query using Bulk v2 API for large datasets:
EXEC dbo.SLAM_query
@query = 'SELECT * FROM Opportunity WHERE CreatedDate > LAST_N_DAYS:365',
@table = 'Opportunity_query',
@api = 'bulkv2'