Reputation: 2915
I have a table in DB2 which I query to obtain a number of specific records which are of interest to me.
Now, I want to generate an insertion script for this data. The export option provided doesn't work for me because I need to provide the generation script to my client.
I read here about the possibility of using a third party tool such as DBArtisan. However, I do not have the possibility of downloading a third party tool.
I use System i Navigator with DB2® for IBM®.
EDIT: Based on @WarrenT 's question, I add more information so as to help improve my question.
Assuming the SQL statement I have to query the database is
SELECT * FROM my_table WHERE colValue>='500'
One of the suggested answers was to do:
INSERT INTO target_table
SELECT * FROM my_table WHERE colValue>='500'
Although I do agree it would be the best solution, I cannot do this because in the target environment they do not have the table "my_table". I'm no expert in the different script types, I know I need the typical script
INSERT INTO target_table (parm1, parm2,...) VALUES (val1, val2,...)
Upvotes: 1
Views: 8447
Reputation: 4542
So you have a SQL query that selects the records you to be inserted into another table?
You probably simply want to use the INSERT command. If you are going to populate all the columns in your target table, then you can use this format:
INSERT INTO your_target_table
SELECT your query goes here;
This works if the columns returned by your query match up to the columns in the destination table. If not, then you have to list the target columns you will be populating.
See INSERT in the SQL Reference manual for more details.
Upvotes: 2