# Database Tables not Created

**URL:** <https://forum.inductiveautomation.com/t/database-tables-not-created/17998>\
**Category:** Ignition\
**Tags:** ignition79, database\
**Created:** [May 11, 2018, 4:19pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998 "2018-05-11T16:19:47Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![m.stretti](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@m.stretti](https://forum.inductiveautomation.com/u/m.stretti)\
**Post date:** [June 25, 2021, 3:22pm UTC](https://forum.inductiveautomation.com/t/database-tables-not-created/17998/12 "2021-06-25T15:22:05Z")

</div>

I ran into the same issue:  
I have different schemas in my database and datasources.  
Ignition created historian tables only for the first datasource and not for the others. And historian is throwing errors because the tables are not there.

I worked around it by manually adding the tables in the schemas and adding a trigger that would add the tables partitions whenever ignition adds a line in the “sqlth\_partitions” table…

````auto
CREATE OR ALTER TRIGGER tai_qlt_sqlth_partitions ON SCADA.qlt.sqlth_partitions
AFTER INSERT
AS
BEGIN
DECLARE @tablename NVARCHAR(100)
SET @tablename = (SELECT TOP 1 pname FROM INSERTED )
DECLARE @insert_query NVARCHAR(MAX);
SET @insert_query =CONCAT(N'CREATE TABLE SCADA.qlt.', @tablename,' (
		tagid int NOT NULL,
		intvalue bigint NULL,
		floatvalue float NULL,
		stringvalue nvarchar(255) COLLATE Latin1_General_CI_AS NULL,
		datevalue datetime NULL,
		dataintegrity int NULL,
		t_stamp bigint NOT NULL,
		CONSTRAINT PK __sqlt_dat__', @tablename,' PRIMARY KEY (tagid,t_stamp)
	)
 	CREATE NONCLUSTERED INDEX ', @tablename,'t_stampndx ON qlt.', @tablename,' ( t_stamp ASC )  
	WITH ( PAD_INDEX = OFF ,FILLFACTOR = 100 ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON )
	 ON [PRIMARY] ')
EXEC sp_executesql @insert_query
END```
````

---

_[View the full topic](https://forum.inductiveautomation.com/t/database-tables-not-created/17998)._
