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 brewdaddy@gmail.com 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]