Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Advanced SQL to update from insert
Message
 
 
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:
01564148
Vues:
38
>>>It is part of the select columns list, in other words, you're selecting the PK from your version table using the above technique.
>>
>>After the first SQL, I execute another SQL like this:
>>
>>
>>UPDATE Version SET NoVersionProduction=Temp2.Numero
>>FROM Version
>>JOIN
>>(
>>SELECT VersionProduction.Numero,VersionProduction.Date,Temp.Numero AS VersionNumero FROM VersionProduction
>>INNER JOIN (SELECT CAST(Version.Date AS Date) AS Date,Version.Numero
>>FROM Version
>>WHERE Version.Date>'1899-12-30 00:00:00.000') Temp
>>ON Temp.Date=CAST(VersionProduction.Date AS Date)
>>) Temp2 ON Temp2.VersionNumero=Version.Numero
>>
>>
>>This works.
>>
>>As for the CTE, it this SQL ANSI?
>
>I believe CTE is SQL Server syntax, but it is probably supported in other databases.

One of the best SQL Server experts I know says he doesn't get why CTE is not more widely used. He says it will give you a performance boost by orders of magnitude. He was in my office one day and filled the whiteboard with notes about it. I said that was so good I'm buying you lunch. Jimmy John's, his choice. That was the most valuable lunch I ever bought anyone.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform