We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The implementation use the following pattern: select TOP 0 * from ( {{ select_sql }} ) as __dbt_sbq where 0 = 1
When select_sql contains CTEs (with) this will fail as TSQL does not support this syntax. A possible solution would be to use something like this:
{% macro sqlserver__get_columns_in_query(select_sql) %} {% set get_columns_in_query -%} SELECT name FROM sys.dm_exec_describe_first_result_set ('{{ escape_single_quotes(select_sql) }}', NULL, 0) {% endset %}
{{ return (run_query(get_columns_in_query).columns[0].values() | list ) }}
{% endmacro %}
It works with any TSQL select statement.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The implementation use the following pattern:
select TOP 0 * from (
{{ select_sql }}
) as __dbt_sbq
where 0 = 1
When select_sql contains CTEs (with) this will fail as TSQL does not support this syntax.
A possible solution would be to use something like this:
{% macro sqlserver__get_columns_in_query(select_sql) %}
{% set get_columns_in_query -%}
SELECT name
FROM
sys.dm_exec_describe_first_result_set
('{{ escape_single_quotes(select_sql) }}', NULL, 0)
{% endset %}
{% endmacro %}
It works with any TSQL select statement.
The text was updated successfully, but these errors were encountered: