Copy data between rows in the same table

So here was my issue. I needed to copy some <binary data> from one row in a table to another row. I tried using the SQL Server Managment Studio but it does not allow you to copy and past binary information. Instead I used a UPDATE... FROM SQL statement.

Here is an example:

UPDATE LoadTestRun
SET LoadTest = b. LoadTest
FROM LoadTestRun, LoadTestRun b
WHERE LoadTestRun.LoadTestRunID = 4 AND b.LoadTestRunID = 1  

Here is the generic format:

UPDATE table
SET field = b.field
FROM table, table b
WHERE table.PirmaryKeyID = "Copy To ID" AND b.PrimaryKeyID = "Copy From ID"  

Comments

Popular posts from this blog

Add User As Local Administrator On Domain Controller

Calling Dataverse Web API in PowerShell using Client Credentials

Windows Server 2008R2 VMs Shut Down After 1 to 2 Hours