Greetings all - it's been a long time...

It doesn't help that I'm pretty rusty at this sort of thing and I'm sure
the answer is obvious, but I am struggling with this INSERT query this
morning.

I want to populate a lookup table with all the distinct values from a
column in a different table.

Here's the INSERT query:

INSERT INTO [dbo].[FMDFPRI]
           ([SPri]
           ,[descr]
       ,[created]
       ,[edited])
  select p.priority as Spri
        ,p.priority as descr
    ,'20161201092101946CSS01   ' as created
    ,'20161201092101946CSS02   ' as edited
from FMDFSRQ p
where p.priority <> '' and
p.priority not in (select Spri from fmdfpri)
GO


I get this error message:

Violation of PRIMARY KEY constraint 'FmSPriKey'. Cannot insert duplicate
key in object 'dbo.FMDFPRI'. The duplicate key value is (2               ).


Can anyone help?


-- 
Matt Jarvis
Eugene, Oregon USA


--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/capt54rzbxbzcgvindbo5f9aobc0nrjp_8zsdavm4wy2dvrp...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to