-
how to insert data with multiple values
hi i have another problem, i have a data which has a multiple data. and i need to get only one record per quotation number for my header table. im trying to use distinct function but still it returns many records. so im thinking maybe i can insert it using procedure. first i need to get the quotation number then apply distinct function, then i will now get the data according to quotation number that i get from the previous query. but the little problem is on my code and i need you help once again for this. here is how i do it:
BEGIN
declare count integer;
declare @quodate varchar(12),
declare @quotation_no varchar(20),
declare @attention varchar(30),
declare @invoiceno varchar(20),
declare @quote1 varchar(20)
declare mycursor cursor for select quotation_ from #tm;
declare cursor1 cursor for select quotation_,company_na,date_,attn,sales_code,invoic e_no from newquotedata where quotation_ = @quote1;
OPEN mycursor;
quotation:loop;
set count=0;
FETCH NEXT mycursor;
INTO @quote1 ;
if sqlcode <> 0 then leave quotation end if;
open cursor1;
fetch next cursor1 into @quotation_no,@quodate,@attention,@invoiceno;
insert into quotation (quotation_no,quodate,attention,invoiceno) values (@quotation_no,@quodate,@attention,@invoiceno);
close cursor1;
set count=count+1;
end loop:quotation;
close mycursor;
END
hope somebody can help me
thanks a lot
johds
-
Tried with 'top 1' in select statement?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|