schemachange icon indicating copy to clipboard operation
schemachange copied to clipboard

snowchange appears to truncate my del statement

Open TimNapierVST opened this issue 2 years ago • 4 comments

Hi,

Im trying to execute `USE DATABASE {{db_name}}; alter session set QUERY_TAG = 'DDL'; {%- set str_schema_name = 'DATA_MART' -%} {%- set str_table_name = 'DIM_CLIENT' -%} {%- set str_column_name = 'INDUSTRY' %}

USE DATABASE {{db_name}}; {%- set str_schema_name = 'DATA_MART' -%} {%- set str_table_name = 'DIM_CLIENT' -%} {%- set str_column_name = 'INDUSTRY' %}

begin if ( not exists( select * from information_schema.columns where table_schema = '{{str_schema_name}}' and table_name = '{{str_table_name}}' and column_name = '{{str_column_name}}' ) ) then begin alter table {{str_schema_name}}.{{ str_table_name }} ADD COLUMN {{str_column_name}} varchar(100); return '{{str_schema_name}}.{{str_table_name}}.{{str_column_name}} added'; end; else return '{{str_schema_name}}.{{str_table_name}}.{{str_column_name}} already exists'; end if; end;`

and when it is executed, it truncates to

`use database timn_db_blue; begin if ( not exists( select * from information_schema.columns where table_schema = 'DATA_MART' and table_name = 'DIM_CLIENT' and column_name = 'INDUSTRY' ) ) then begin alter table DATA_MART.DIM_CLIENT ADD COLUMN INDUSTRY varchar(100);

`

Is this supported, if not, is there a way I can check for the existence of the column prior to running the alter statement.

TimNapierVST avatar Jan 19 '23 22:01 TimNapierVST