August 7, 2007 at 12:40 pm
as I'm sure there's a good article out there, I have yet to find it.
Pretty much what I'm doing is querying invoices out of Quickbooks into a table. Then I'm running some operations and stuff on the table. When all that is done I want to move all that data to an "archive" table and clean out the table I just used.
It's the typical routine of stage data, operate on data, archive data, clear stage.
and I do not know how to do it, because I'm just an applications guy trying to cross over more into the DB universe.
My boss suggested using cursors. I replied with a blank empty stare.
HELP!
August 7, 2007 at 1:57 pm
Rough Example
In books online it is the Insert..Select
Insert into Mytable (col2, col3, col5)
Select SourceCol1, SourceCol2, SourceCol4
From StageTable
Where Something = Something
From BOL
The SELECT subquery in the INSERT statement can be used to add values into a table from one or more other tables or views. Using a SELECT subquery also lets more than one row be inserted at one time.
This INSERT statement inserts into a separate table some of the data from all the rows in titles whose type is modern cooking:
USE pubsINSERT INTO MyBooks SELECT title_id, title, type FROM titles WHERE type = 'mod_cook'
The select list of the subquery must match the column list of the INSERT statement. If no column list is specified, the select list must match the columns in the table or view being inserted into.
Another use of the INSERT...SELECT statement is to insert data from
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply