Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Advanced SQL to update from insert
Message
 
 
To
25/01/2013 14:00:32
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01564084
Message ID:
01564113
Views:
25
>>
>>;with cte as (select cast(Version.[Date] as Date) as [DateNoTime], *, 
>>COUNT(*) OVER (partition by cast(Version.[Date] as Date)) as cntVersionsPerDay, 
>>row_number() over (partition by cast(Version.[Date] as Date) ORDER BY Version.[Date] DESC) as Rn
>> from dbo.Version)
>>
>>insert into VersionProduction (AddUser, AddDate, ....)
>>
>>select ....
>>
>>from cte where Rn = 1
>
>But, what is updating Version.NoVersionProduction in there?

It is part of the select columns list, in other words, you're selecting the PK from your version table using the above technique.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform