首页 > 解决方案 > 将数据从表中的一个单元格复制然后插入到该表中的另一个单元格

问题描述

我有一个 SQL Server 数据库表,它有一个名为 PersonPhoto 的字段(它的数据是二进制图片),我需要将 PersonPhoto 从 person with 插入到 PersonPhoto 的personCode=11字段中,用于另一个 Person with personCode=5。如何使用 T-SQL 做到这一点?

标签: sql-servertsql

解决方案


试试这个 :

Update Person
Set PersonPhoto = (Select Top(1) PersonPhoto From Person where pesronCode = 11)
Where pesronCode=5

此外,您可以使用这样的变量:

Declare @PersonPhoto as Varbinary(Max)

保存到变量然后使用它


推荐阅读