RE: force sql server to handle a subquery as correlated
From: Jan Schoenrock (Schoenrock_at_discussions.microsoft.com)
Date: 07/16/04
- Next message: Eddy: "Re: Filtering a QUERY between two datetime values"
- Previous message: David Portas: "Re: avg of two fields"
- In reply to: Nitin Rana: "force sql server to handle a subquery as correlated"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Jul 2004 02:27:02 -0700
Hello Nitin,
thanks for your help. Your suggstion might be helpful if there is no other who can insert data to the table a the same time, when running the loop.
Thanks again and best greetings
Jan
"Nitin Rana" wrote:
> My only suggestion is store the initial highest value in
> a variable and just keep on incrementing the variable
> value instead of running MAX(PKID) on each insert. But,
> you do need to do it in a loop. I don't see any shortcut.
>
>
> >-----Original Message-----
> >Hi,
> >
> >I have the following question. Does anybody have an
> idea ?
> >
> >I want to insert a resultset of a select statement into
> a table wich has a non automated primary key.
> >So for each record I have in my resultset I need to
> generate a new PK by using a subquery:
> >
> >Insert into I(PKID, PKHist, IA,IB,IC)
> >Select
> >(Select MAX(PKID)+1 From I)
> >1,
> >XA,
> >XB,
> >YC
> >From X,Y
> >
> >So insert and select has to be handled together step by
> step.
> >select the first, insert the first, select the second,
> insert the second.
> >
> >If there is a possibility to force such an behavior it
> can be very smart.
> >
> >My only solution is to run such an insert by using loops
> or cursors.
> >
> >I'll be very appreciate to receive some ideas ...
> >
> >thanks in advance
> >
> >Jan
> >
> >
> >
> >.
> >
>
- Next message: Eddy: "Re: Filtering a QUERY between two datetime values"
- Previous message: David Portas: "Re: avg of two fields"
- In reply to: Nitin Rana: "force sql server to handle a subquery as correlated"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|