# Insert a table in a database in SQLServer database to anothe

**URL:** <https://forum.inductiveautomation.com/t/insert-a-table-in-a-database-in-sqlserver-database-to-anothe/9214>\
**Category:** Ignition\
**Created:** [October 22, 2014, 10:37pm UTC](https://forum.inductiveautomation.com/t/insert-a-table-in-a-database-in-sqlserver-database-to-anothe/9214 "2014-10-22T22:37:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mireya.enriquez1](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mireya.enriquez1](https://forum.inductiveautomation.com/u/mireya.enriquez1)\
**Post date:** [October 22, 2014, 10:37pm UTC](https://forum.inductiveautomation.com/t/insert-a-table-in-a-database-in-sqlserver-database-to-anothe/9214/1 "2014-10-22T22:37:45Z")

</div>

Hello, I have the following problem, I need to insert a table from a database in SQLServer database to another MySQL, however I can not insert the data to the alert table that I created and I do not see the error, my script is as follows:

If you could give me a help, thanks

insert a table in a database in SQLServer database to another on MySQL

desde=system.tag.read("[]desde")  
alarmas = system.db.runScalarQuery(“SELECT DateTime, Text1, Text3, State FROM AlgViewESP WHERE DateTime\>=”"+ desde.value+"" ORDER BY DateTime ASC ",“COBOCE\_ALGVIEWESP”)  
i=0  
while i\<alarmas.rowcount  
DateTime=alarmas(i,0)  
Text1=alarmas(i,1)  
Test3=alarmas(i,2)  
State=alarmas(i,3)  
system.db.runScalarQuery(“INSERT INTO alarm (DateTime, Text1, Text3, State) VALUES (?,?,?,?)”,[DateTime, Text1, Text3, State] ,“COBOCE\_ALGVIEWESP”)

If you could give me a help, thanks!!

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [October 23, 2014, 4:54am UTC](https://forum.inductiveautomation.com/t/insert-a-table-in-a-database-in-sqlserver-database-to-anothe/9214/2 "2014-10-23T04:54:27Z")

</div>

[code]desde=system.tag.getTagValue("[]desde")  
alarmas = system.dataset.toPyDataSet(system.db.runPrepQuery("SELECT DateTime, Text1, Text3, State FROM AlgViewESP WHERE DateTime\>=? ORDER BY DateTime ASC ",[desde],“COBOCE\_ALGVIEWESP”))

for row in alarmas:  
DateTime=row[“DateTime”]  
Text1=row[“Text1”]  
Text3=row[“Text3”]  
State=row[“State”]  
system.db.runPrepUpdate(“INSERT INTO alarm (DateTime, Text1, Text3, State) VALUES (?,?,?,?)”,[DateTime, Text1, Text3, State] ,“COBOCE\_ALGVIEWESP”)[/code]
