Is the ID column the first one in your list of insert columns? SPri You can rt click on the table and go to Script Table as, then use insert to, and have it write out the plain Jane code for this table's insert.
On Mon, Sep 25, 2017 at 11:22 AM, M Jarvis <[email protected]> wrote: > 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 > --- > [excessive quoting removed by server] _______________________________________________ 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/cajidmy+acl7gurfm8+flwyahq03ffvmbmeohreufroyfw3-...@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.

