[英]How to get auto generated Id before insertion?
Try to concate the two column values and Use UPDATE
statement to update the value in the related column. 尝试串联两个列的值,并使用
UPDATE
语句更新相关列中的值。
CREATE TABLE Test (
IdWithChar NVARCHAR(MAX),
ImageAddress NVARCHAR(MAX),
CoverImage NVARCHAR(MAX)
)
INSERT INTO Test VALUES ('B00001','Test Address','Test-Image-Url')
Query: 查询:
UPDATE TEST
SET CoverImage= IdWithChar +' '+ ImageAddress
WHERE Your_condition
first you must insert values and get the last identity and then update the field in the record. 首先,您必须插入值并获取最后的身份,然后更新记录中的字段。
insert into item values ('test', 'test')
declare @itemId int = @@IDENTITY
update item set item_code = @itemId where item_id = @itemId
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.