Skip to content

TODO

This code-generation template creates table creation scripts for Sql Server, exactly as per the defintion of the data object.

After importing data definitions from operational systems, a typical next step is generating source objects to load the data delta into. This template creates these tables. This template can also be used to generate data solution objects like for like.

  • SQL Server family databases

This template can be assigned to any data object definition.

[!NOTE] Exactly the same structure is used as is defined in the data object definition. E.g. no standard data solution or framework columns are added.

N/A.

--
-- Source table creation statement for [{{lookupExtension dataConnection.extensions "datastore"}}].[{{lookupExtension dataConnection.extensions "location"}}].[{{name}}].
--
-- Generated from template '{{templateMetadata.name}}'.
--
DROP TABLE IF EXISTS [{{lookupExtension dataConnection.extensions "datastore"}}].[{{lookupExtension dataConnection.extensions "location"}}].[{{name}}];
CREATE TABLE [{{lookupExtension dataConnection.extensions "datastore"}}].[{{lookupExtension dataConnection.extensions "location"}}].[{{name}}]
(
{{#each dataItems}}
[{{name}}] {{stringupper dataType}}{{#if characterLength}}({{characterLength}}){{/if}}{{#if numericPrecision}}({{numericPrecision}},{{numericScale}}){{/if}},
{{/each}}
CONSTRAINT [PK_{{name}}] PRIMARY KEY CLUSTERED
(
{{#each ./dataItemsMetadata.keyDataItems}}
[{{stringupper @value}}]{{#unless @last}},{{/unless}}
{{/each}}
)
);