Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (35 sloc) 3.07 KB
{# --============================================================================== -- #}
{# -- -- #}
{# -- DBMS Name : SQL Server -- #}
{# -- Template Name : nu3_sqlserver_ddl_view_stage -- #}
{# -- Description : This template creates a stage view based on the meta data -- #}
{# -- Author : Eckhard Zemp -- #}
{# -- -- #}
{# --============================================================================== -- #}
{# -- -- #}
{# -- Notes / History -- #}
{# -- 20171102 | Eckhard Zemp | Initial Creation -- #}
{# -- 20171212 | Eckhard Zemp | Finally found a way to reuse the stage block -- #}
{# -- -- #}
{# --============================================================================== -- #}
{#- Load some utility macros #}
{%- import "nu3_sqlserver_utility_configuration" -%}
{%- import "nu3_sqlserver_utility_elements" -%}
{%- import "nu3_sqlserver_utility_snippets" -%}
{%- import "nu3_sqlserver_utility_ddl" -%}
{#- Variables #}
{%- set templateVersion = "20171212" -%}
{%- set sysObjectType = "VIEW" -%}
{%- set targetTableSchema = getTableTargetSchema() | trim -%}
{#- Properties #}
{%- if table.viewInfo.distinct is defined %}{%- endif %}
{%- if table.viewInfo.whereClause is defined %}{%- endif %}
{#- Drop Table #}
{{- addDropTable(table.target) }}
{#- Create View #}
{%- fetch table.target %}
CREATE OR ALTER VIEW [{{ targetTableSchema }}].[{{ table.name }}]{% br %}
({% br %}
{{- addInsertColumns(indent = " ")}}){% br %}
AS{% br %}
{%- include "nu3_sqlserver_block_select_stage" with {"indent":" ","mergeTable":""} %}