i'm having a sql master table CHANNEL_PT
which i want to fill based on two other master tables CHANNEL and PT.
the CHANNEL_PT cosist of three colums CHANNEL_PT_CD, CHANNEL_CD and PT_CD.
the scenario to insert records into CHANNEL_PT is such that,
if i am having two entries in the CHANNEL table,

and two entries in PT table as below,

then the CHANNEL_PT table would be as below

i knew that this can be done with CURSOR but i'm not using it due to performance concern.
i have written the query as below to get the expected result but want to know any other more efficient way or optimized query.
BEGIN TRANSACTION
DECLARE @CH INT;
DECLARE @CH_CNT INT;
DECLARE @CH_MAX INT;
SELECT @CH_MAX = MAX(CHANNEL_CD) FROM CHANNEL;
SELECT @CH = ISNULL(MIN(CHANNEL_CD),0),@CH_CNT=COUNT(CHANNEL_CD) FROM CHANNEL WHERE CHANNEL_CD > -1
WHILE @CH <= @CH_MAX
BEGIN
DECLARE @PT INT;
DECLARE @PT_CNT INT;
DECLARE @PT_MAX INT;
SELECT @PT_MAX = MAX(PT_CD) FROM PT;
SELECT @PT = ISNULL(MIN(PT_CD),0),@PT_CNT=COUNT(PT_CD) FROM PT WHERE PT_CD > -1
WHILE @PT <=@PT_MAX
BEGIN
DECLARE @CPT INT;
SELECT @CPT = ISNULL(MAX(CHANNEL_PT_CD),0) FROM CHANNEL_PT
IF NOT EXISTS(SELECT CHANNEL_CD,PT_CD FROM CHANNEL_PT WHERE CHANNEL_CD=@CH and PT_CD=@PT)
BEGIN
INSERT INTO CHANNEL_PT VALUES(@CPT+1,@CH,@PT)
END
SELECT @PT = MIN(PT_CD) FROM PT WHERE PT_CD > @PT
END
SELECT @CH=MIN(CHANNEL_CD) FROM CHANNEL WHERE CHANNEL_CD > @CH
END
COMMIT;