Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Advanced SQL to update from insert
Message
 
 
À
25/01/2013 14:00:32
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01564084
Message ID:
01564113
Vues:
26
>>
>>;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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform