Microsoft SQL Server Stage Files
Applies to
Platform: Microsoft SQL Server
Architecture: Stage
Microsoft SQL Server Stage Files generates a Stage layer for SQL Server that loads CSV files, as T-SQL scripts with stored procedure loaders. Select the Generator Configuration Microsoft SQL Server Stage File when you add a project whose sources are CSV files.
The configuration works with CSV source systems only. For source databases use Microsoft SQL Server Stage.
Scope and output
- Platform: Microsoft SQL Server on Windows.
- Layers: Source and Stage. Dataflow Modeling shows Stage in the Bronze column. See Understand the Layering concept.
- Output: the layer script
SQL\L010_Stage.sql, one format file per Stage in the folderFormat, the load control scripts or an Airflow DAG, and the PowerShell 7 scripts that deploy and load, described in Microsoft SQL Server - Artifacts.
Each arrow in the diagram is a dataflow between two layers:

Prerequisites
- A SQL Server instance and a login that can create the databases, schemas and objects of the layers and the load control. The deployment creates missing databases, with the recovery model
SIMPLE, and schemas. - PowerShell 7 and sqlcmd on the machine that deploys.
- The extended stored procedure
xp_cmdshellenabled on the instance. - Four folders on the SQL Server host for the CSV files, the format files, the archive and the error files, with the permission Modify for the SQL Server service account.
The setup is described in Microsoft SQL Server - Target environment, the placeholders in Microsoft SQL Server - Placeholder values.
Sources and linked projects
The source system has the type Csv. The CSV options of a Stage, such as File Group Pattern, are described in CSV options (Model Object). The discovery types are listed in Source systems per generator configuration.
You can export this project as a linked project. The configuration cannot import linked projects.
Supported model objects
Capabilities and limitations
- Raw data: each Stage gets a table
STG_ST_<model object name>_RawDatawith oneNVARCHAR(MAX)column per file column. Its loader_RawDataLoaderfills it. - Reading files: the loader lists the matching files with
xp_cmdshelland reads each file withOPENROWSET(BULK ...), the format file<model object name>.fmtandFORMAT = 'CSV'. - Source view:
_Sourcecasts the raw columns to the data types of the terms.BG_SourceSystemholds the path of the loaded file. - Without
xp_cmdshellthe loader stops with error 50001SQL Server instance is not configured for xp_cmdshell. - Keys: Stage tables have no primary key and no hash columns. Increment tables
<table name>_Incrementhave the identity columnBG_ID INT IDENTITY. - Indexes: Index management offers clustered and nonclustered rowstore and columnstore indexes, unique indexes and Included Columns.
- Deployment: with the default Deployment Options, each deployment drops and creates the tables again. See Microsoft SQL Server - Deployment.
Project properties
The configuration offers no Hash Algorithm. It offers these project properties, with their defaults:
- Begin of Universe:
19000101 - Create Result Views: on
- Target Object Comment Type:
None; alsoTablesandTables and Views - Artifact Output Mode:
Layer Composites; alsoDeployment Objects - Deployment Options:
Generate Drop Table Statements - Configure LoadControl: on
- Deploy LoadControl: on
- LoadControl Options:
Native Load Control; alsoAirflow
Data types
Default Term data types by platform lists the data types of the Default Terms on Microsoft SQL Server.
Platform differences
These profiles compare their configuration with this one:
Example
A Stage dataflow_mapped_sourcesystem reads CSV files with invoice data. It generates this raw data table and source view. The excerpt shows the example schema st and the example database DWH in place of the placeholders and leaves out the other file columns:
CREATE TABLE [st].[STG_ST_dataflow_mapped_sourcesystem_RawData] (
[BG_LoadTimestamp] DATETIMEOFFSET NOT NULL
,[BG_SourceSystem] NVARCHAR(255) NULL
,[INVOICE_NO] NVARCHAR(MAX) NULL
,[CUSTOMER_ID] NVARCHAR(MAX) NULL
,[DELIVERY_DATE] NVARCHAR(MAX) NULL
)
;
CREATE VIEW [st].[STG_ST_dataflow_mapped_sourcesystem_Source]
AS
SELECT
[BG_LoadTimestamp] AS [BG_LoadTimestamp]
,ISNULL([BG_SourceSystem], N'Source1') COLLATE DATABASE_DEFAULT
AS [BG_SourceSystem]
,CAST([s1].[INVOICE_NO] AS NVARCHAR(20)) COLLATE DATABASE_DEFAULT
AS [INVOICE_NO]
,CAST([s1].[CUSTOMER_ID] AS INT) AS [CUSTOMER_ID]
,CAST([s1].[DELIVERY_DATE] AS DATE) AS [DELIVERY_DATE]
FROM [DWH].[st].[STG_ST_dataflow_mapped_sourcesystem_RawData] AS [s1]
;
The file Format\dataflow_mapped_sourcesystem.fmt of the artifacts describes the file columns for OPENROWSET.
Release differences
Project Settings shows the Generator Version of your project.
- Generator 2.2: the project properties Persist Validity and Create Result Views; the model object property Increment Management Type on Stage.
Related articles
- Previous:
- Microsoft SQL Server: Target environment
- Next: Generate artifacts, Replace the placeholders in the artifacts
- Microsoft SQL Server: Artifacts, Deployment, Load data - Native load control, Load data - Apache Airflow load control
- Reference: CSV options (Model Object), File Group Pattern (Model Object), Artifact Output Mode (Project), Deployment Options (Project), LoadControl Options (Project)
- Microsoft SQL Server: Placeholder values
- See also: Available Generator Configurations, Understand the Generator Configuration, Source systems per generator configuration
- Microsoft SQL Server: Stage, Stage OpenQuery, Data Store, Data Vault, Dimensional