我試圖將數據從數據庫複製到另一個數據庫如何在插入語句SQL Server中設置訂單計數?
我有這個疑問
insert into d1.dbo.Category(Id, Name, CategoryTemplateId,
ParentCategoryId, PictureId, PageSize,
AllowCustomersToSelectPageSize,
ShowOnHomePage, IncludeInTopMenu,
SubjectToAcl, LimitedToStores, Published,
Deleted, DisplayOrder,
CreatedOnUtc, UpdatedOnUtc)
select
(ItemID + 25), ItemName, 1,
(CategoryID + 16), '', 6,
1, 1, 1, 0, 0, 1, 0, 1,
iif(CreateDate is null, GETDATE(), CreateDate),
iif(LastModifyDate is null, GETDATE(), LastModifyDate)
from
d2.dbo.Item
它工作正常。問題是:有一列DisplayOrder
如果我使用這種語法,它會在行中插入1,但我真正需要的是計數1,2,3,4,..等
取決於(CategoryID + 16)
直到(CategoryID + 16)
改變了它從1開始計數再次
請幫
你爲什麼不能使用身份屬性 – TheGameiswar