I have a Table named as Table1 as below
ID, JobNo, Date, Comments
I have a View named as View1 created with the help of Synonyms from another Read Only Table as below,
ID, JobNo, StartSeq, EndSeq
The column ID is a Primary Key. And I will have to UPDATE Table1 with the Data for columns ID and JobNo from View1.
Lets say View1 has 2 rows and I will INSERT those 2 rows into Table1. So when View1 gets its 3rd row, how do I update the Table1 with the info on 3rd row, without deleting the Data thats previously stored in Table1.
Right now, I have the following query but it doesn’t seem to work because of the Duplicate Primary Key issue.
INSERT INTO Table1(ID, JobNo)
SELECT View1.ID, View1.JobNo
FROM View1
I’m a newbie to SQL so please help me out with this
Assuming you only want to
INSERTnew data on table1 and not actuallyUPDATEthe data that you already have, then you should do: