INSERT if not exists

BEGIN IF NOT EXISTS(SELECT * FROM [OwnersInCompany] WHERE [CompanyID] = @CompanyID AND [OwnerID] = @OwnerID) BEGIN INSERT INTO [OwnersInCompany] ([CompanyID], [OwnerID]) VALUES (@CompanyID, @OwnerID) END END

Leave a Reply

Your email address will not be published. Required fields are marked *