SQL触发器获取刚插入ID
createtriggerMytriggerontb_Testforinsertasbeginend现在我要写一个插入触发器,怎么获取刚插入的ID打印出来(ID是自动增长...
create trigger Mytrigger on tb_Test
for insert
as
begin
end现在我要写一个插入触发器,怎么获取刚插入的ID 打印出来(ID是自动增长的!) 展开
for insert
as
begin
end现在我要写一个插入触发器,怎么获取刚插入的ID 打印出来(ID是自动增长的!) 展开
2013-07-14
展开全部
create table info
(
id int identity primary key,
[name] varchar(10)
)
go
create trigger trig_insert
on info for insert
as
begin
declare @id int
select @id=id from inserted
print @id
end
insert into info values('123')
(
id int identity primary key,
[name] varchar(10)
)
go
create trigger trig_insert
on info for insert
as
begin
declare @id int
select @id=id from inserted
print @id
end
insert into info values('123')
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询