I have a stored procedure that creates table A and fills it with data each month so that my reports can run from table A.
Now they would like to see this month's reports start out with last months ending balance (one of the fields in table A). That is a calculated field and not stored in the database so I was thinking I would just copy table A to table B before dropping Table A each month.
This is something I have never done before - the other stored procedure was already there. Would it be best to create a stored procedure that runs first and drops table B then creates table B and does an update query to fill it with data from table A (before table A gets dropped and recreated)?
I mean, there's not an easier way like a copy table command or something is there? I looked in SQL Server books online but didn't see anything like that.
And how do you do an update query to update one table from another? Is it:
Update Table B
set field1 = tableA.field1 ?
I don't really have anything for the Where since I just want to load everything into Table B from Table A.
Thank you
Now they would like to see this month's reports start out with last months ending balance (one of the fields in table A). That is a calculated field and not stored in the database so I was thinking I would just copy table A to table B before dropping Table A each month.
This is something I have never done before - the other stored procedure was already there. Would it be best to create a stored procedure that runs first and drops table B then creates table B and does an update query to fill it with data from table A (before table A gets dropped and recreated)?
I mean, there's not an easier way like a copy table command or something is there? I looked in SQL Server books online but didn't see anything like that.
And how do you do an update query to update one table from another? Is it:
Update Table B
set field1 = tableA.field1 ?
I don't really have anything for the Where since I just want to load everything into Table B from Table A.
Thank you