insert into temptable1  select *  from  GetDatas(@BookID,@DraftDate) 
if @@error <> 0 
 .....

解决方案 »

  1.   

    游标:
    declare @BookID tinyint
    declare @DraftDate datetime
    declare Cur cursor for
    SELECT BookID,DraftDate FROM [book]open  Cur
    fetch next from Cur into(@BookID,@DraftDate)
    while @@fetch_status=0
    begin
    insert into temptable1  select *  from  GetDatas(@BookID,@DraftDate) 
    insert into temptable2  select *  from  GetDatas(@BookID,@DraftDate)fetch next from Cur into @BookID,@DraftDate
    endclose Cur
    deallocate Cur
    --------------------
    游标差不多这个意思,
      

  2.   

    BEGIN TRANSACTION 
    ......
    if @@error<>0
    rollback
    else
    COMMIT TRANSACTION 
    错误就回滚