begin tran
declare @state varchar(2),
@productId int
declare stateCursor CURSOR FOR
select distinct [State]
from lookUpAreaFactor
declare productCursor CURSOR FOR
select distinct productid
from Product
open stateCursor
open productCursor
FETCH NEXT from stateCursor into @state
fetch next from productCursor into @productId
while @@FETCH_STATUS = 0
BEGIN
while @@FETCH_STATUS = 0
BEGIN
insert into ProductToState (ProductID,[State]) values (@productId,@state)
fetch next from productCursor into @productId
END
fetch next from stateCursor into @state
END
close stateCursor
close productCursor
select * from producttostate
rollback