Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Refresh denormalized fields

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

Leave a Reply

Your email address will not be published. Required fields are marked *



En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!

Om...

Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   linktr.ee/hesselbom   |   winsoft.se   |   80tal.se   |   Filmtips