sql-server - 将数据从表中的一个单元格复制然后插入到该表中的另一个单元格
问题描述
我有一个 SQL Server 数据库表,它有一个名为 PersonPhoto 的字段(它的数据是二进制图片),我需要将 PersonPhoto 从 person with 插入到 PersonPhoto 的personCode=11
字段中,用于另一个 Person with personCode=5
。如何使用 T-SQL 做到这一点?
解决方案
试试这个 :
Update Person
Set PersonPhoto = (Select Top(1) PersonPhoto From Person where pesronCode = 11)
Where pesronCode=5
此外,您可以使用这样的变量:
Declare @PersonPhoto as Varbinary(Max)
保存到变量然后使用它
推荐阅读
- mysql - 如何在for循环中进行sql查询并将查询存储在表中
- caching - 为什么 Bit-PLRU 与 LRU 不同
- javascript - 在 JavaScript 中格式化 HTML、CSS 和 JavaScript 代码的最佳方式是什么
- javascript - 使用@ViewChild 按类名选择元素?
- json - 无法获取称为属性“属性”的键值:“值”Groovy
- bash - 想要在 MacOS 上的某个时间运行脚本,而是返回 'job 4 at Wed Jun 12 16:55:00 2019'
- c# - 单击注销按钮时无法到达控制器/操作
- javascript - 有没有办法在不同的滚动点更改不同的图像?
- jquery - 如何使用 JQuery 和 Ajax 将一维数组传递给 php 页面?
- php - 以 Laravel 形式创建对象数组