sql - 创建一个虚拟值
问题描述
我正在 SSIS 和 SQL Server 中创建数据仓库。现在为了处理迟到的尺寸,我想用代理键 -999 创建一个虚拟值。让我们以我的Products
表为例,我已经拥有了ProductID
,而Product_pk
which 是我的代理键。
代理键是自动生成的。有没有办法用特定的代理键插入一个虚拟值?
解决方案
您可以通过在会话中设置参数来插入标识值,identity_insert
.
set identity_insert products off;
insert into products (productId, . . .)
values (-1, . . . )
set identity_insert products on;
请注意,会话中只能identity_insert
关闭一个表。所以,你应该在完成后重新打开它。
推荐阅读
- docker-compose - 使用 `links` 指令迁移 docker-compose 文件
- reactjs - NX React - 如何为库创建默认模拟
- python - switch/toogle 导致 BadRequestKeyError: 400 Bad Request
- qt - 如何获得带有枚举的 QDialog 的子项(访问按钮)?
- c# - 具有用户定义表类型的 SQL Server 存储过程
- hive - 查找值是否属于 impala 中的一组值
- swift - 如何更改 UIButton 的背景颜色?
- linux - Azure 总线服务队列消息处理
- python - 使用 Python BS4 循环抓取图像源的问题
- javascript - 在 React MDX 博客中打印和下载图像