force sql server to handle a subquery as correlated
From: Nitin Rana (Nitin_at_discussions.microsoft.com)
Date: 07/16/04
- Next message: Tom Moreau: "Re: restore from script- exclusive access"
- Previous message: Tom Moreau: "Re: Using a calculated column in a WHERE clause"
- In reply to: Jan Schoenrock: "force sql server to handle a subquery as correlated"
- Next in thread: Jan Schoenrock: "RE: force sql server to handle a subquery as correlated"
- Reply: Jan Schoenrock: "RE: force sql server to handle a subquery as correlated"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 15 Jul 2004 18:26:40 -0700
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: Tom Moreau: "Re: restore from script- exclusive access"
- Previous message: Tom Moreau: "Re: Using a calculated column in a WHERE clause"
- In reply to: Jan Schoenrock: "force sql server to handle a subquery as correlated"
- Next in thread: Jan Schoenrock: "RE: force sql server to handle a subquery as correlated"
- Reply: Jan Schoenrock: "RE: force sql server to handle a subquery as correlated"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|