I have the following SQL Command:
INSERT INTO mstr_lists (mstr_list_item_id,mstr_list_type,mstr_list_item_desc,list_order,cache_ind,delete_ind,create_timestamp,created_by,modify_timestamp,modified_by, show_in_emr_ind,enterprise_id,practice_id,nxmd_ind)
select distinct NEWID(),'location',txt_provider_lname ,0,'N','N',GETDATE(),'817',GETDATE(),'817','Y','00000','0000','N' from patient_provider_role_ where txt_provider_lname is not null and txt_provider_lname != ''
and txt_provider_lname not in
(select mstr_list_item_desc from mstr_lists where mstr_list_type = 'location')
I get error message:
Msg 2601, Level 14, State 1, Line 1
Cannot insert duplicate key row in object 'dbo.mstr_lists' with unique index 'ak_mstr_lists1'.
The statement has been terminated.
I double checked and there were no duplicates in the query as I have used distinct in my select?
Can someone help me figure this out?
Thanks in advance!