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?