Skip to main content

SLAM_query

This command provides generalized query support with the API provided as a @api query parameter. @batch_size is only relevant to SOAP API and @pkchunksize is only relevant to Bulk v1 API.

Parameters:

NameTypeDefaultDescription
@queryNVARCHARRequiredsObject name or SOQL query string. When just an sObject name is passed, queries all records & fields
@tableVARCHARRequiredTarget SQL table name for results
@apiNVARCHARRequiredAPI to use ('bulk', 'bulkv2', or 'soap')
@pkchunksizeINTNULLEnable PK chunking (Bulk v1 API only). If NULL, PK chunking is disabled
@batch_sizeINT2000Number of records per batch (SOAP API only)
@queryallBIT0When 1, includes deleted/archived records
@exists_actionVARCHAR(20)SLAM_Settings.default_exists_actionAction to take if the target object name specified by @table is already taken. If NULL, uses the value from SLAM_Settings.default_exists_action (defaulted to 'drop' during initial setup).

Valid options:
  • 'drop'
  • 'rename'
  • 'fail'

Usage Examples:

Query using Bulk 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'