Create a unique constraint on a column based on distinct value from another column in the same table
Seems like this should do it:

CREATE UNIQUE INDEX [UNQ_locationName_companyId]
ON dbo.[locations]([locationName],[companyId]);