# Create database on MSSQL through Scripting

**URL:** <https://forum.inductiveautomation.com/t/create-database-on-mssql-through-scripting/55406>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [January 26, 2022, 3:45pm UTC](https://forum.inductiveautomation.com/t/create-database-on-mssql-through-scripting/55406 "2022-01-26T15:45:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbarker](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cbarker](https://forum.inductiveautomation.com/u/cbarker)\
**Post date:** [January 26, 2022, 3:45pm UTC](https://forum.inductiveautomation.com/t/create-database-on-mssql-through-scripting/55406/1 "2022-01-26T15:45:04Z")

</div>

Hello all  
I have been making a script in Igntion that runs on project save. It is to verify the database structure against a passed in structure, so that changes can be made in ignition rather than having to open management studio.

I have all of the required functions working except for one. This is the ability to create a new connection AND new database entry on a preconfigured driver. For example, if connection name “LOCALMSSQL” is not the default connection, it will use the supplied driver name, username, and password along with the searched for connection name to create a new connection. This works sing system.db.addDatasource()

I then want the ability to add database to the database server that LOCALMSSQL connects to. For example connection.addDatabase(“project1”) or some equivalent. It could be part of the addDatasource as well.

Is there anything currently that does this, or is management studio still required to make the initial database?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 26, 2022, 4:43pm UTC](https://forum.inductiveautomation.com/t/create-database-on-mssql-through-scripting/55406/2 "2022-01-26T16:43:15Z")

</div>

> **[CREATE DATABASE (Transact-SQL) - SQL Server](https://docs.microsoft.com/en-us/sql/t-sql/statements/create-database-transact-sql?view=sql-server-ver15&tabs=sqlpool)**
>
> Create database syntax for SQL Server, Azure SQL Database, Azure Synapse Analytics, and Analytics Platform System

Looks like you just need to issue a well formed SQL statement.

---

<div class="post-metadata">

**Author:** ![cbarker](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cbarker](https://forum.inductiveautomation.com/u/cbarker)\
**Post date:** [January 26, 2022, 4:59pm UTC](https://forum.inductiveautomation.com/t/create-database-on-mssql-through-scripting/55406/3 "2022-01-26T16:59:27Z")

</div>

Thank you for your help. I managed to get the connection to work and create a database inside it. Is there a way to set the Extra Connection Properties from scripting except to drop and readd the connection?
