sql语句

select lastrun into #temp 
from dbo.spt_monitor
select * from #temp


BEGIN TRY
  BEGIN TRAN
         select lastrun into #temp 
                from dbo.spt_monitor
          select * from #temp
  COMMIT TRAN
  END TRY
  
  --如果同步过程中出错,则事务回滚,并且记录数据库返回的错误信息和出错的数据的ID
  BEGIN CATCH
  ROLLBACK
DECLARE @msg nvarchar(2000)=ERROR_MESSAGE()    --将捕捉到的错误信息存在变量@msg中               
    RAISERROR (@msg,16,1)    --此处才能抛出(好像是这样子....)
drop table Temp 
END CATCH
原文地址:https://www.cnblogs.com/shikyoh/p/2140451.html