i create a table tbl_channelpartner
where cpcode is 8 digit
my aim is when i generate guid 8 digit first it check that it not exists in cpcode if exist then create new one
purpose is uniqnes between cpcode it is primary key in my case
i write this query but it not work
SELECT SUBSTRING(CONVERT(VARCHAR(255), NEWID()),0,9) where NOT IN ( select cpcode from tbl_channelpartner)