Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Advanced SQL to update from insert
Message
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01564084
Message ID:
01564148
Views:
40
>>>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform