on ‎2013 Oct 04 1:03 PM
declare @product_code char(10),@rowNR int,@Mrow int set i=1 select product_code,row_number() over(order by parent_id) as rowNR,parent_id into #FT_1 from product_code where parent_id='cp' //select * from #ft_1 //select @mrow=max(rowNR) from #ft_1 //select @mrow while i<=29 LOOP select @product_code=product_code from #ft_1 where i=rownr select @product_code set i=i+1 end loop select * from #t1
error loop

Request clarification before answering.
You have a syntax error because you are running a series statements without any separators. You need a semi-colon between separate statements eg:
declare @product_code char(10),@rowNR int,@Mrow int set i=1; select product_code,row_number() over(order by parent_id) as rowNR,parent_id into #FT_1 from product_code where parent_id='cp'; //select * from #ft_1 //select @mrow=max(rowNR) from #ft_1 //select @mrow while i<=29 LOOP select @product_code=product_code from #ft_1 where i=rownr; select @product_code; set i=i+1; end loop
also you haven't declared i
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
declare @product_code char(10),@rowNR int,@Mrow int
declare i
set i=1
select product_code,row_number() over(order by parent_id) as rowNR,parent_id into #FT_1 from product_code where parent_id='cp'
//select * from #ft_1
//select @mrow=max(rowNR) from #ft_1
//select @mrow
while i<=29 LOOP
select @product_code=product_code from #ft_1 where i=rownr;
select @product_code;
set i=i+1;
end loop
error for set i=1
@mfkpie8: Have you read the answers by Justin and Mark? They clearly explain the problem (mixing T-SQL and Watcom-SQL syntax). And you are still mixing these dialects. Sigh.
| User | Count |
|---|---|
| 9 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.