hello everybody,
I have a small problem and was hipeing someone could help. Want to run a query, where I sellect results from two tables. Once this is done I want to takes those results and update a table that is already created with those results. How would I do this? Thw eonly way I know how to do this is by writing this:
select CompanyName, ContactName, Address, City, Region, ProductName, UnitPrice INTO TABLE2
From Suppliers, Products
But the problem with this is that I can only input the query results into a new table that I would name above. I can't insert it into a table that has already been created.
This is the erroe that I receive:
There is already an object named 'TABLE2' in the database.
Please Help!
thanksINSERT INTO TABLE2 (
CompanyName
, ContactName
, Address
, City
, Region
, ProductName
, UnitPrice)
SELECT
CompanyName
, ContactName
, Address
, City
, Region
, ProductName
, UnitPrice
From Suppliers, Products
I'd also say you're missing a JOIN|||So say that information changes on the 2 tables that I am querying, when I run this insert code with the query, it will reinsert all the records into table2, which will basically be updating it. Am i getting this right? Thats what I am trying to do. I could also turn that into a job so that it could run automatically right?
thanks|||Inserting will add records to the table unless you have constraints that prevent duplicate records/keys. Updating modifies the original field(s) of the record you are working with. Are you new to database design ?|||Can you elaborate what you are trying to do ?|||Originally posted by rnealejr
Inserting will add records to the table unless you have constraints that prevent duplicate records/keys. Updating modifies the original field(s) of the record you are working with. Are you new to database design ?
Actually yes, I am new to this. Thats probably why I sound redundante. So I need as much help as possibel
thanks|||Originally posted by rnealejr
Can you elaborate what you are trying to do ?
Okay, here it goes. I created a table called "table1". This table has all the columns named already. I want to hold records from a a query that I run on two other tables and then place the results in table2. The colums that I query are named the same as the columns I created in table2. I just want all those records to show up in table2.|||Aren't you planning on using the code I posted?|||Originally posted by Brett Kaiser
Aren't you planning on using the code I posted?
ACTUALLY i USED IT AND IT WORKED WELL. i WAS JUST WONDERING IF THERE WERE OTHER WAYS OF DOING IT.
THANKS FOR YOUR HELP. i AM PRETTY NEW AT THIS.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment