【发布时间】:2021-03-24 22:34:22
【问题描述】:
我需要在我的插入查询中自动增加一个 id。
DECLARE @parts_table TABLE( partid int,qty float,cost numeric(10,2),hrb int) /*create parts_table */
/*Insert data to created table*/
INSERT INTO @parts_table (partid,qty,cost,hrb)
SELECT part_id ,unit_cost,qty,hrb_id FROM asset_parts
Declare @product_codes Parts_Codes
while exists(select * from @parts_table where hrb=1 or hrb=3)
Begin
Insert into @product_codes(id ,code) Values(null,'')
end
这里读取表中的所有数据,并根据我需要向 Parts_Codes 插入数据的数量。向表中插入数据时,我需要自动增加 id。 有什么办法吗?
【问题讨论】:
标签: insert ssms auto-increment temp-tables