--====================================
--SCOPE_IDENTITY()函数使用: 只返回插入到当前作用域中的值
--返回在当前会话中的任何表内所生成的最后一个标识值
--另外两个函数 floor ,Ceiling
--select floor(12.99) select Ceiling(12.01)
--====================================
if object_id('tempdb..#BatchPool') is null
begin
create table #BatchPool
(
BatchID bigint identity,
Value int
)
end
declare @BatchID bigint
insert into #BatchPool(Value)
select floor(rand()*1000)
select *
from #BatchPool
select @BatchID = SCOPE_IDENTITY();
select @BatchID
--drop table #BatchPool