# Check if a database table exists before proceeding?

**URL:** <https://community.easymorph.com/t/check-if-a-database-table-exists-before-proceeding/4249>\
**Category:** General Q&A\
**Created:** [January 30, 2023, 9:19pm UTC](https://community.easymorph.com/t/check-if-a-database-table-exists-before-proceeding/4249 "2023-01-30T21:19:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flowy](https://community.easymorph.com/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@flowy](https://community.easymorph.com/u/flowy)\
**Post date:** [January 30, 2023, 9:19pm UTC](https://community.easymorph.com/t/check-if-a-database-table-exists-before-proceeding/4249/1 "2023-01-30T21:19:35Z")

</div>

Hi community,

I have a morph that imports data into SQL. The issue is if the table doesn't exist then I want it created and imported into that table. That part is done with with the Custom SQL that I run prior to the export.

The issue I have is if the data I'm retrieving is already existing in the table, I want it to skip it.

The vision I see here is,

1. Query the table, if the table exists, then merge the table and remove those that are matching rows

I tried to do this by using a Database command, where I could check the object\_id from the sys.objects table to see if it exists but it doesn't seem to do or return anything. If I run this with a existing or non existing table results are the same, just blank (no errors).

Any idea how I could do this?

Thanks  
Flowy

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [January 30, 2023, 9:34pm UTC](https://community.easymorph.com/t/check-if-a-database-table-exists-before-proceeding/4249/2 "2023-01-30T21:34:34Z")

</div>

The "Database command" action now has the "List tables" command, so you can check if the table already exists.

 ![image](https://community.easymorph.com/uploads/default/original/2X/0/026c2f293240ad662650fffd2be68ded850ab2d6.png)

---

<div class="post-metadata">

**Author:** ![flowy](https://community.easymorph.com/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@flowy](https://community.easymorph.com/u/flowy)\
**Post date:** [January 30, 2023, 9:40pm UTC](https://community.easymorph.com/t/check-if-a-database-table-exists-before-proceeding/4249/3 "2023-01-30T21:40:38Z")

</div>

Hi Dmitry,

Will this work by parameter?

Thanks  
Flowy

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [January 30, 2023, 9:57pm UTC](https://community.easymorph.com/t/check-if-a-database-table-exists-before-proceeding/4249/4 "2023-01-30T21:57:30Z")

</div>

Hi Flowy,

What do you mean?

---

<div class="post-metadata">

**Author:** ![flowy](https://community.easymorph.com/letter_avatar_proxy/v4/letter/f/e95f7d/32.png) [@flowy](https://community.easymorph.com/u/flowy)\
**Post date:** [January 30, 2023, 11:06pm UTC](https://community.easymorph.com/t/check-if-a-database-table-exists-before-proceeding/4249/5 "2023-01-30T23:06:59Z")

</div>

Thank Dmitry!!! I just tested it and your right this will work!!!

Flowy
