大量数据时建议使用存储过程提高效率同时进行错误处理begin try begin transaction insert into types values(@typename,@blogman) insert into bloginfo values(@blogman,@blogtitle,@blogcontent,@@identity,getdate(),0) commit transaction return @@identity end try begin catch rollback transaction return 0 end catch
用事务吧,如果出现异常让其回滚,然后判断是否回滚让起重新执行.