# system.db.runScalarQuery command works in Script Console but not in Calculated Pipeline script

**URL:** <https://forum.inductiveautomation.com/t/system-db-runscalarquery-command-works-in-script-console-but-not-in-calculated-pipeline-script/29294>\
**Category:** Ignition\
**Tags:** ignition80, scripting, database\
**Created:** [October 22, 2019, 5:52pm UTC](https://forum.inductiveautomation.com/t/system-db-runscalarquery-command-works-in-script-console-but-not-in-calculated-pipeline-script/29294 "2019-10-22T17:52:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [October 22, 2019, 5:52pm UTC](https://forum.inductiveautomation.com/t/system-db-runscalarquery-command-works-in-script-console-but-not-in-calculated-pipeline-script/29294/1 "2019-10-22T17:52:44Z")

</div>

I have a system.db.runScalarQuery script that works in Script Console but not in Calculated Pipeline script. Any ideas why?

NewV = system.db.runScalarQuery(“SELECT COUNT(\*) FROM NewTable where id = 1 AND date IS NULL”)

If commented out in the Calculated Pipeline script runs as it should. In the Script Console I can just add a “Print NewV” and it works fine.

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [October 22, 2019, 6:03pm UTC](https://forum.inductiveautomation.com/t/system-db-runscalarquery-command-works-in-script-console-but-not-in-calculated-pipeline-script/29294/2 "2019-10-22T18:03:03Z")

</div>

Have you tried adding your database name into it?

```auto
NewV = system.db.runScalarQuery(“SELECT COUNT(*) FROM NewTable where id = 1 AND date IS NULL”,"Your DB Name")

```

---

<div class="post-metadata">

**Author:** ![r123](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@r123](https://forum.inductiveautomation.com/u/r123)\
**Post date:** [October 22, 2019, 6:43pm UTC](https://forum.inductiveautomation.com/t/system-db-runscalarquery-command-works-in-script-console-but-not-in-calculated-pipeline-script/29294/3 "2019-10-22T18:43:57Z")

</div>

That worked!

So in the Script Console it grabs the default database but elsewhere, maybe not. 🙂
