Sweety
Sweety

Reputation: 191

Specify sql variable in dbt

I want to specify this select statement in my dbt model:

select @rowcount from <xxx table>

Where the @rowcount variable defines as int. Can any one suggest me to represent this in DBT?

Upvotes: 0

Views: 1182

Answers (2)

SantiMunoz
SantiMunoz

Reputation: 21

You can use a window functions depending on your SQL dialect!

Big Query || Snowflake || SQLServer || AWS:

SELECT row_number() over () as row_count, *
from <xxx table>

Upvotes: 0

sgdata
sgdata

Reputation: 2763

If this is in SQL Server, isn't the syntax @@RowCount?

Pre-supposing that, there are two in development dbt "Adapter" projects to SQL Server:

Per the docs on supported dbs:

Depending on your version, I would recommend opening an issue for that particular variable if it doesn't work as-is.

Upvotes: 1

Related Questions