# Issues Transferring Tag Historian data to a new database table

**URL:** <https://forum.inductiveautomation.com/t/issues-transferring-tag-historian-data-to-a-new-database-table/71569>\
**Category:** Ignition\
**Created:** [March 24, 2023, 6:13pm UTC](https://forum.inductiveautomation.com/t/issues-transferring-tag-historian-data-to-a-new-database-table/71569 "2023-03-24T18:13:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_kensett](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@jason\_kensett](https://forum.inductiveautomation.com/u/jason_kensett)\
**Post date:** [March 24, 2023, 6:13pm UTC](https://forum.inductiveautomation.com/t/issues-transferring-tag-historian-data-to-a-new-database-table/71569/1 "2023-03-24T18:13:17Z")

</div>

I have a database with a table that is just for a couple epa tags and alarm events. I was using the tag historian before the was set up and now i have to get the old data moved over. This is the last one I tried. I have the return size on 2 so that I can make sure I see it working before I do the rest.

```auto
pathofTag = ['[Ignition403DB]/oxidizers/oxidizer/chamber_avg']
starttime = system.date.parse('2023-01-06 00:00:00', 'yyyy-dd-MM HH:mm:ss') 
endtime = system.date.parse('2023-03-14 11:14:36', 'yyyy-dd-MM HH:mm:ss')

results = system.tag.queryTagHistory(paths=pathofTag, startDate=starttime, endDate=endtime, returnSize=2, returnFormat='Wide')
pyData = system.dataset.toPyDataSet(results)

dataBase = "EPA_403"

for row in pyData:
	time = row[0]
	temp = row[1]
	system.db.runPrepUpdate("INSERT INTO dbo.epatable (t_stamp, chamber_avg) VALUES (?, ?)",[time, temp], dataBase)
```
