# AdHoc Trend Template

**URL:** <https://forum.inductiveautomation.com/t/adhoc-trend-template/17828>\
**Category:** Ignition\
**Created:** [April 25, 2018, 12:01pm UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828 "2018-04-25T12:01:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CJVR](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@CJVR](https://forum.inductiveautomation.com/u/CJVR)\
**Post date:** [April 25, 2018, 12:01pm UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828/1 "2018-04-25T12:01:53Z")

</div>

The AdHoc Trend Template on the cloud is great. But it seems a number of tables need to be set up in the database to handle saved graphs, annotations, etc. Are there instructions floating around on how to set up the back end? Are they included and I’m just being dense?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 25, 2018, 12:33pm UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828/2 "2018-04-25T12:33:00Z")

</div>

The inspiration for the ad-hoc trend template was IA’s original “Click-To-Graph” collection of scripts and exported windows. The forum search has many hits on the above and on “ctg” that will give you some background. The key tables for pens, axes, and subplots basically mimic the columns that the chart customizer produces.

---

<div class="post-metadata">

**Author:** ![CJVR](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@CJVR](https://forum.inductiveautomation.com/u/CJVR)\
**Post date:** [April 25, 2018, 12:44pm UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828/3 "2018-04-25T12:44:00Z")

</div>

Never mind… The code to create the tables is in the save graph and save annotation buttons. They depend on a custom property of a couple of labels. I changed the project database and the **exists** custom property of the labels was inconsistent with reality. So, it works when you install it into a “clean” project.

---

<div class="post-metadata">

**Author:** ![wschauer](https://avatars.discourse-cdn.com/v4/letter/w/ecccb3/32.png) [@wschauer](https://forum.inductiveautomation.com/u/wschauer)\
**Post date:** [July 23, 2018, 8:08pm UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828/4 "2018-07-23T20:08:52Z")

</div>

Hi am am having a similar issue working with the ad-hoc trend template. I have read through most of the ctg forum answers but many of them are geared towards 7.7 and earlier. I am using 7.9 and getting the error that the table sqlth\_te doesn’t exist but from what I understand this was used only with the ctg. Is this something that needs to be created separately to query the DB tags? Thanks!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 23, 2018, 8:10pm UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828/5 "2018-07-23T20:10:36Z")

</div>

The sqlth\_te table is automatically created by Ignition when a tag is set to record history into that database.

---

<div class="post-metadata">

**Author:** ![wschauer](https://avatars.discourse-cdn.com/v4/letter/w/ecccb3/32.png) [@wschauer](https://forum.inductiveautomation.com/u/wschauer)\
**Post date:** [July 24, 2018, 4:14pm UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828/6 "2018-07-24T16:14:27Z")

</div>

Ah ok thanks. Do you know if the same type of Ad-hoc chart is available for non historical SQL tags?

---

<div class="post-metadata">

**Author:** ![OscarLucas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/oscarlucas/32/6417_2.png) [@OscarLucas](https://forum.inductiveautomation.com/u/OscarLucas)\
**Post date:** [August 3, 2020, 9:00am UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828/7 "2020-08-03T09:00:24Z")

</div>

I need the SQL code to generate “ignition.chart\_annotations” table. I just have the one for save the graf.  
CREATE TABLE `saved_graphs` (  
`id` INT NOT NULL AUTO\_INCREMENT,  
`title` VARCHAR(45) NOT NULL,  
`tagpens` LONGTEXT NOT NULL,  
`axes` LONGTEXT NOT NULL,  
`username` VARCHAR(45) NULL,  
`lastmodified` DATETIME NOT NULL,  
PRIMARY KEY (`id`))

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 3, 2020, 1:03pm UTC](https://forum.inductiveautomation.com/t/adhoc-trend-template/17828/8 "2020-08-03T13:03:37Z")

</div>

```auto
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[chart_annotations](
	[id] [int] NOT NULL,
	[penname] [nvarchar](50) NULL,
	[xvalue] [nvarchar](50) NULL,
	[yvalue] [nvarchar](50) NULL,
	[note] [nvarchar](50) NULL,
	[enteredby] [nvarchar](50) NULL,
	[lastupdated] [datetime] NULL
) ON [PRIMARY]
GO

```
