Append query and add an identifier?

G

Guest

I have a local database which imports orders from a SQL table from an on-line
shopping cart.

When I do the append query, I need add an identifier to indicate on my local
orders table that the appended record came from the on-line shopping cart.
I'm going to be updating this order table with local, point of sale
transactions.

I'm planning on creating a unique key between Row ID & this text identifier
(let's call the field "Type"). So, the unique key for the order table will
be a combination of ROW ID & Type. Online transations would be Row ID 1 +
Type = "Web". For point of sales transactions, the unique key would be Row
ID 1 + Type ="Store".

When I'm doing the Append query to update the orders table on the local db
from the online tables, how do I add the column to to add the text "Web" into
a the type column on the orders table as my source tables to not have this
identifying column?
Do I have to run an immediate "Update" query or can I just have some SQL in
the append query to perform this action?
 
M

MGFoster

D said:
When I'm doing the Append query to update the orders table on the local db
from the online tables, how do I add the column to to add the text "Web" into
a the type column on the orders table as my source tables to not have this
identifying column?

INSERT INTO table_name (col1, col2, col3)
SELECT "Web", column2, column3
FROM import_table

Putting the constant value "Web" in the SELECT clause will cause that
value to be stored in col1 of table_name.
 
G

Guest

I've attempted the insert function on the append query, so the entire SQL for
this action looks like:

INSERT INTO Registration
SELECT [dbo_Registration Without Matching Registration].*
FROM [dbo_Registration Without Matching Registration]
INSERT INTO Registration (Source)
SELECT "Web",Source
FROM dbo_Registration

I'm a little confused...I don't have have a field "Source" from
dbo_Registration...all I'm trying to do is put the text "Web" into the Source
field on the Registration table. Can I even have two INSERT functions in the
SQL statement?
 
G

Guest

I'd like to combine the two following actions ....how do I put this together?
1) the append function:

INSERT INTO Registration
SELECT [dbo_Registration Without Matching Registration].*
FROM [dbo_Registration Without Matching Registration]

2) the update function:
UPDATE Registration SET Registration.Source = "Web";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top