Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Advanced SQL to update from insert
Message
From
25/01/2013 14:37:28
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01564084
Message ID:
01564137
Views:
31
>I re-read your problem. I guess you want to grab PK from the Production version and put them in FK in the Version, right?
>
>I see the problem now, so
>
>create table #Output (Numero, [Date] datetime)
>
>insert into ...
>
>OUTPUT Inserted.Numero, Inserted.[Date] into #Output (Numero, [Date])
>select ....
>
>Update Version Set FK = O.Numero
>from Version INNER JOIN #Output O on Version.[Date] >= O.[Date] and Version.[Date] < dateadd(day,1, O.[Date])
Thanks, I will consider this approach for upcoming requests like that. I do not know if it is easier to understand however and SQL ANSI.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform