# Preventing a sql script from running again?

**URL:** <https://forum.ansible.com/t/preventing-a-sql-script-from-running-again/12331>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [February 10, 2013, 11:48pm UTC](https://forum.ansible.com/t/preventing-a-sql-script-from-running-again/12331 "2013-02-10T23:48:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Romeo\_Theriault](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Romeo\_Theriault](https://forum.ansible.com/u/Romeo_Theriault)\
**Post date:** [February 10, 2013, 11:48pm UTC](https://forum.ansible.com/t/preventing-a-sql-script-from-running-again/12331/1 "2013-02-10T23:48:59Z")

</div>

What Lorin pointed you at is good but if you're running the script against  
a remote sql server you might have to create a task ahead of the sql script  
task, which checks if the schema exists and store the result in a register  
variable. That way you can check if it's created or not. Something like  
this:

tasks:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- action: command /some/script/to/check\_if\_shema\_exists.sql  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: schema\_exists

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- action: command /script/to/create\_shema.sql  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when\_string: "'${schema\_exists.stdout}' == "no"

---

<div class="post-metadata">

**Author:** ![Simon\_Rascovsky](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Simon\_Rascovsky](https://forum.ansible.com/u/Simon_Rascovsky)\
**Post date:** [February 11, 2013, 12:11am UTC](https://forum.ansible.com/t/preventing-a-sql-script-from-running-again/12331/2 "2013-02-11T00:11:55Z")

</div>

Ah…ok, that makes sense…running against a variable set by a checking script…will try it out, thanks!
