# Source freshness - selecting target database

**URL:** <https://discourse.getdbt.com/t/source-freshness-selecting-target-database/7359>\
**Category:** Help\
**Tags:** snowflake, dbt-core\
**Created:** [March 17, 2023, 3:31am UTC](https://discourse.getdbt.com/t/source-freshness-selecting-target-database/7359 "2023-03-17T03:31:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex.t](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/alex.t/32/1986_2.png) [@alex.t](https://discourse.getdbt.com/u/alex.t)\
**Post date:** [March 17, 2023, 3:31am UTC](https://discourse.getdbt.com/t/source-freshness-selecting-target-database/7359/1 "2023-03-17T03:31:53Z")

</div>

## dbt source freshness for a specific database

Hey, trying to check the freshness of the source but not sure how to select the target database.  
I’m running this first

> `dbt source freshness --select source:DATABASENAME`

as I have other sources in yml file and then

> `dbt run --target first`

but during the freshness check dbt randomly selects the target database.  
Does anyone know how to solve it?  
Can I use `--target` together with` dbt source freshness` command?

## This is my code

```auto
sources:
  - name: DATABASENAME
    schema: STAGE
    database: |
      {%- if target.name == "first" -%} STAGING_FIRST
      {%- elif target.name == "second" -%} STAGING_SECOND
      {%- endif -%}

    freshness: # default freshness
      warn_after: {count: 12, period: hour}
      error_after: {count: 24, period: hour}
    loaded_at_field: insert_date

    tables:
      - name: orders
        freshness: 
          warn_after: {count: 6, period: hour}
          error_after: {count: 12, period: hour}

```

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [March 17, 2023, 2:20pm UTC](https://discourse.getdbt.com/t/source-freshness-selecting-target-database/7359/2 "2023-03-17T14:20:08Z")

</div>

I am not 100% sure, but I think you can use `--target` in `dbt source freshness`, have you tried it?

---

<div class="post-metadata">

**Author:** ![alex.t](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/alex.t/32/1986_2.png) [@alex.t](https://discourse.getdbt.com/u/alex.t)\
**Post date:** [March 20, 2023, 12:36am UTC](https://discourse.getdbt.com/t/source-freshness-selecting-target-database/7359/3 "2023-03-20T00:36:07Z")

</div>

Yeah, it worked actually 🙂 Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [March 27, 2023, 12:36am UTC](https://discourse.getdbt.com/t/source-freshness-selecting-target-database/7359/4 "2023-03-27T00:36:09Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
