27,579
社区成员
发帖
与我相关
我的任务
分享
declare @t table(id int identity ,col varchar(20))
--插入一条数据
insert into @t
select cast(rand() as varchar(20))
--得到刚插入的数据
select * from @t where id=@@identity
insert into tb
select ...
select top 1 * from tb order by 主键 desc
if object_id('tb')is not null drop table tb
go
create table tb(Id int identity,name nvarchar(10))
insert tb output inserted.ID select '张三'
/*
ID
-----------
1
*/
create TABLE test(id int IDENTITY PRIMARY KEY ,col varchar(20))
--插入一条数据
insert into test
select 'record1'
--得到刚插入的数据
select * from test where id = SCOPE_IDENTITY()