Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: RE : Sql Server Stored Procedure


Message #1 by "Pierre" <pierre.mathieu@s...> on Tue, 21 Aug 2001 19:15:05 -0700
Hello!



You Can do it without cursor



Insert into realfigure

select * from rawfigure where id not in (select id from realfigure)



-----Message d'origine-----

De=A0: Priyadarshini [mailto:vnimesh@y...]

Envoy=E9=A0: Monday, August 20, 2001 12:38 PM

=C0=A0: ASP Databases

Objet=A0: [asp_databases] Sql Server Stored Procedure



Hi All..

              Thanx for yr support.. I need a urgent help.. can anyone

help me pls.. well.



               I have two tables within a same databse in sqlserver. The



tables are named as rawfigure and realfigure. The task is, the datas in

the rawfigure table should be inserted into the realfigure table,but

only

the new values. We have a id column. So each and every record in the raw



table must be checked against the realtable id, if the id is not there

then insert it into the realfigure table,if id is there just update the

realfigure values with rawfigure values...



My stored procedure is not working.. i think the total coding is wrong..



and i am new in writing stored procedure.. so pls go thru my code and

someone please help me.. u can modify my code and send the new one so

that

i can use it straight away in my application... thanx in advance.



The code is:



------



CREATE PROCEDURE sp_balaproc

as

begin

declare @tid1 char(5),@tdateofjoin1 datetime



 declare balacur1 scroll cursor  for  select * from rawfigure

 declare balacur2 scroll cursor for select * from realfigure



        open balacur1

        fetch next from balacur1 into @tid1,@tdateofjoin1

        while @@fetch_status <> -1

        open balacur2

        fetch next from balacur2 into @tid2,@tdateofjaoin2

        if @tid1=3D@t... then

        begin

         insert into realfigure values (@tid1,@tdateofjoin1)

        end             

return

end

------------------



Regards,

P'darshini.








  Return to Index