I have the following unique contstraint defiend on a table:
CREATE UNIQUE NONCLUSTERED INDEX [IX_Access_AccessSOE] ON [dbo].[Access]
(
[AccessSOE] ASC
)
I am trying to import records to this table using the following query:
INSERT INTO Access
(AccessSOE, AccessName, AccessBox, AccessLocation,
AccessBusiness, AccessPhone, AccessFax, AccessEmail,
LastUpdatedBy, Deleted, AccessPrimaryKey)
SELECT DISTINCT(i.AccessSOE), i.AccessName, i.AccessBox, i.AccessLocation,
i.AccessBusiness, i.AccessPhone, i.AccessFax, i.AccessEmail,
'Admin', 0, i.IndexNew
FROM Access_IMPORT i
WHERE i.AccessSOE NOT IN (SELECT a.AccessSOE FROM ACCESS a)
However the import fails. The only unique constraint on the table is the AccessSOE field, and I thought by selecting only distinct items, my query would be correct.
Can anyone provide any help?