# Help with SQL Query to write data from one DB table to another for a monthly report

**URL:** <https://forum.inductiveautomation.com/t/help-with-sql-query-to-write-data-from-one-db-table-to-another-for-a-monthly-report/62075>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [July 19, 2022, 5:02pm UTC](https://forum.inductiveautomation.com/t/help-with-sql-query-to-write-data-from-one-db-table-to-another-for-a-monthly-report/62075 "2022-07-19T17:02:26Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![mwolter](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mwolter](https://forum.inductiveautomation.com/u/mwolter)\
**Post date:** [July 21, 2022, 4:41pm UTC](https://forum.inductiveautomation.com/t/help-with-sql-query-to-write-data-from-one-db-table-to-another-for-a-monthly-report/62075/21 "2022-07-21T16:41:33Z")

</div>

Another way to approach this problem, if you have access to SQL Server Management Server is to Create a View using the SQL QUERY provided by IRose without the WHERE And ORDER BY clause.  
Then you can use a simple SELECT Query to access your data and the VIEW is reusable

You can look up the Syntax on [docs.microsoft.com](http://docs.microsoft.com) or in any SQL book but it is basically putting

Create View [dbo].[vViewName] as in front of your SQL statement

This eliminates the need for table C and rejoining the tables anytime you need to access the data  
Matt

---

<div class="post-metadata">

**Author:** ![Amreesh\_S](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@Amreesh\_S](https://forum.inductiveautomation.com/u/Amreesh_S)\
**Post date:** [July 26, 2022, 3:34am UTC](https://forum.inductiveautomation.com/t/help-with-sql-query-to-write-data-from-one-db-table-to-another-for-a-monthly-report/62075/22 "2022-07-26T03:34:21Z")

</div>

Hi,

Why you need to insert into third table C. You can make a query with A and B (Both tables are must fall in same database) , then show the result in your report, it is the easiest way I think.

Thanks.

---

<div class="post-metadata">

**Author:** ![BLG](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@BLG](https://forum.inductiveautomation.com/u/BLG)\
**Post date:** [July 26, 2022, 4:51pm UTC](https://forum.inductiveautomation.com/t/help-with-sql-query-to-write-data-from-one-db-table-to-another-for-a-monthly-report/62075/23 "2022-07-26T16:51:49Z")

</div>

After some testing, I was able to get it to work using your combined query and modifying it as needed. I appreciate the help and patience.

[Previous page](https://forum.inductiveautomation.com/t/help-with-sql-query-to-write-data-from-one-db-table-to-another-for-a-monthly-report/62075.md?page=1)
