Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.
2010-09-16
I just had to share this beautiful SQL Server query that I composed today. It refreshes denormalized fields!
UPDATE DestinationTable SET DestinationTable.Field=SourceTable.Field FROM dbo.DestinationTableName AS DestinationTable INNER JOIN dbo.SourceTableName AS SourceTable ON SourceTable.PK=DestinationTable.FK
In other words, it copies the value from one column in one table to another column in another table, where the keys match (specified after ON). Beautiful! I use Microsoft SQL Server 2008, but I’m sure this works in 2005 too.
Categories: Microsoft .NET
Tags: SQL Server
Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!
Leave a Reply