Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sqlserver__alter_column_type macro #169

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

dlarsen5
Copy link

resolves dbt-synapse issue 152 incremental table alter column type syntax error

@dataders
Copy link
Collaborator

dataders commented Nov 5, 2021

thanks @dlarsen5!

@dataders dataders merged commit d25c300 into dbt-msft:master Nov 5, 2021
@panasenco
Copy link

panasenco commented Dec 8, 2021

This macro is not working for me, I'm getting the error [42S22] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid column name 'message__dbt_alter'. (207) (SQLExecDirectW).

SQL Server doesn't seem to support doing multiple updates/alters in a single statement without hacking it with something like EXEC().

FWIW this is not actually a big deal for me because I defined my own custom macro that works just fine. I'm not really sure why the dbt team needed to create a new column, copy data, delete the original column, then rename the new column in their original macro.

{% macro sqlserver__alter_column_type(relation, column_name, new_column_type) %}
  {% call statement('alter_column_type') -%}
    alter {{ relation.type }} {{ relation }} alter column {{ column_name }} {{ new_column_type }};
  {%- endcall -%}
{% endmacro %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

alter_column_type - Not working for column change
3 participants