Bulk Loading and Unloading for Snowflake

Overview

Bulk loading is the fastest way to insert large numbers of rows into a Snowflake table. To use the bulk-load facility, set the BULKLOAD= LIBNAME option to YES. You can also perform bulk unloading (data retrieval) from Snowflake. To enable bulk unloading of data, set the BULKUNLOAD= LIBNAME option to YES.

The SAS/ACCESS engine handles bulk loading and bulk unloading through one of these methods.

Snowflake supports different types of stages.

User and table stages are created automatically. You can create internally named stages with the Snowflake CREATE STAGE command. For details, see your Snowflake documentation.

Use the BL_INTERNAL_STAGE= LIBNAME option or data set option to specify the stage to use for bulk loading or bulk unloading. USER and TABLE are used as placeholders for the respective stages. You can add a path to the location. The internal stage is used by the SAS/ACCESS engine. The engine does not create the stage.

Options for Bulk Loading and Bulk Unloading

Here are the Snowflake bulk-load and bulk-unload options. For detailed information about these options, see Overview.

Except for BULKLOAD= and BULKUNLOAD=, all of these options are supported for bulk loading and bulk unloading.

Snowflake Options for Bulk Loading and Bulk Unloading

Option

Internal Snowflake Staging

External S3 Stage

External Azure Stage

BL_ACCOUNTNAME= LIBNAME and data set options

BL_APPLICATIONID= LIBNAME and data set options

BL_AWS_CONFIG_FILE=LIBNAME and data set options

BL_AWS_PROFILE_NAME= LIBNAME and data set options

BL_AZURE_SAS= LIBNAME and data set options

BL_BUCKET= data set option

BL_COMPRESS= data set option

BL_CONFIG= data set option

BL_DEFAULT_DIR= data set option

BL_DELETE_DATAFILE= data set option

BL_DELIMITER= data set option

BL_DNSSUFFIX= LIBNAME and data set options

BL_ENCKEY= data set option

● (see Encryption with Amazon Redshift)

BL_FILESYSTEM= LIBNAME and data set options

BL_FOLDER= LIBNAME option

BL_INTERNAL_STAGE= data set option

BL_KEY= LIBNAME and data set options

BL_NUM_DATAFILES= data set option

BL_NUM_READ_THREADS= data set option

BL_OPTIONS= data set option

BL_REGION= data set option

BL_SECRET= data set option

BL_TIMEOUT= LIBNAME and data set options

BL_TOKEN= data set option

BL_USE_ESCAPE= data set option

BL_USE_SSL= data set option

BULKLOAD= LIBNAME and data set options

BULKUNLOAD= LIBNAME and data set options

Authentication for Bulk Loading to and Bulk Unloading from Azure

For bulk loading and bulk unloading data files in Azure, additional authentication is required. This authentication uses a Shared Access Signature token that you provide via the BL_AZURE_SAS= LIBNAME or data set option.

Use device-code authentication to access your Azure ADLS location:

Bulk Loading and Bulk Unloading Data Files in Azure ADLS Locations

You can bulk load or bulk unload data files that are stored in an Azure ADLS location. Before you can do this, ensure that you have the necessary values for authentication to Azure ADLS. For more information, see Authentication for Bulk Loading to and Bulk Unloading from Azure.

You can use these options when you bulk load or bulk unload data files in Azure ADLS:

Bulk Loading for PROC FEDSQL and PROC DS2

When you specify BULKLOAD=YES and associated LIBNAME options for bulk loading in the Snowflake LIBNAME statement, these options are automatically included in the connection string that is passed from the engine to PROC FEDSQL and PROC DS2. The BULKLOAD= options and associated data source-specific bulk load options are also available as FedSQL and DS2 table options. For more information, see FedSQL Statement Table Options by Data Source in SAS FedSQL Language Reference or DS2 Statement Table Options by Data Source in SAS DS2 Language Reference.

Examples

Here are some examples for various types of stages using BULKLOAD= and BULKUNLOAD=.

/* Uses the current user stage, @~/test1/ */
libname a snow <connection-options>
   bulkload=yes bulkunload=yes bl_internal_stage="user/test1";
/* Uses the table stage, @%"TABLE_NAME"/test1/, */
/* where TABLE_NAME is replaced with the table to load/unload */
libname a snow <connection-options>
   bulkload=yes bulkunload=yes bl_internal_stage="table/test1";
/* Uses the internal named stage, @MY_INTERNAL_STAGE/test1/ */
libname a snow <connection-options>
   bulkload=yes bulkunload=yes bl_internal_stage="MY_INTERNAL_STAGE/test1";
Note: If BL_INTERNAL_STAGE= is specified, options that support Amazon S3 buckets are ignored.
Last updated: February 3, 2026