SLAM_table_to_csv
Overview
SLAM_table_to_csv is a utility function that exports the entire contents of a SQL Server table to a CSV file. The procedure works entirely with SQL Server data and does not require any Salesforce connection.
Output Format:
- Standard CSV format with comma delimiters, quoted fields, UTF-8 encoding
- All columns from the table are exported
- NULL values are written as empty strings
- Files are named according to their table name unless a custom filename is provided
- By default, files are saved to the work directory.
Empty tables will generate a CSV file with only column headers. The operation is logged in the SLAM_Activity_Log table (if configured).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
@table_name | VARCHAR(255) | Required | Name of the table to export. Use the unqualified name (e.g., Account_Load not dbo.Account_Load) in the configured schema |
@filename | VARCHAR(MAX) | NULL | Custom filename for the CSV output file |
@output_dir | VARCHAR(MAX) | NULL | Output directory. If NULL, files are written to the work directory. Paths with spaces are fully supported (e.g., C:\data exports). Do not attempt to write files to folders the service account doesn't have permissions to (e.g., user folders in C:\Users\), as this will result in a permission error |
Usage Examples
Basic Usage (Default Output)
Export a table using default settings (filename = table name, location = work directory):
EXEC dbo.SLAM_table_to_csv
@table_name = 'Account'
Result: Creates Account.csv in the work directory
Custom Filename
Export with a custom filename:
EXEC dbo.SLAM_table_to_csv
@table_name = 'Account',
@filename = 'Account_backup_2025.csv'
Result: Creates Account_backup_2025.csv in the work directory
Custom Output Directory
Export to a specific directory:
EXEC dbo.SLAM_table_to_csv
@table_name = 'Account',
@output_dir = 'C:\data\exports'
Result: Creates Account.csv in C:\data\exports\
All Parameters Specified
Export with custom filename and directory:
EXEC dbo.SLAM_table_to_csv
@table_name = 'Account',
@filename = 'Account_test.csv',
@output_dir = 'C:\custom folder'
Result: Creates Account_test.csv in C:\custom folder\