我正在尝试从表中获取值并将它们插入到另一个表中。但是,有一个数据库列需要每次增加 1 个值。该值虽然不是标识插入列,但该值来自另一个表。还有另一个 db 列用作计数器。我写了一些东西,但它没有帮助:(121 个文件)
declare @count int;
set @count=0
while @count<=121
begin
insert into cabinet..DOCUMENT_NAMES_ROBBY (TAG,TAGORDER,ACTIVE,QUEUE,REASON,FORM,DIRECT_VIEW,GLOBAL,FU_SIGN,
SIGN_X,SIGN_Y,SIGN_W,SIGN_H,ANNOTATE,doctype_id,CODE,DOC_TYPE,SET_ID,SUSPEND_DELAY,Text_Editing,Restrict_Viewing,Viewing_Expire,
Viewing_Period,DocHdrLength,DocFtrLength,DocRuleId,Outbound,SigQueue,SigReason) select TAG,TAGORDER,ACTIVE,QUEUE,REASON,FORM,
DIRECT_VIEW,GLOBAL,FU_SIGN,
SIGN_X,SIGN_Y,SIGN_W,SIGN_H,ANNOTATE,(select nextid from cabinet..Wfe_NextValue where Name='documents')+1, CODE,DOC_TYPE,'2',SUSPEND_DELAY,Text_Editing,Restrict_Viewing,Viewing_Expire,
Viewing_Period,DocHdrLength,DocFtrLength,DocRuleId,Outbound,SigQueue,SigReason from cabinet..document_names where SET_ID ='1'
update cabinet..Wfe_NextValue set NextID=NextID+1 where Name='documents'
set @count=@count+1
end
该数据库列是 doctype_id。上面显然是错误的,并在表中放置了 14,000 行。基本上我想从 document_names 中获取每一个条目并将其放入 document_names_robby ......除了 doctype_id 列应该从 wfe_nextvalue +1 中获取值,同时在插入下一个文档名称之前将该表中的该数字增加 1进入 document_Names_Robby。任何帮助表示赞赏