我要用存储过程插入一条记录但有一列是IDENTITY
现在我要用带返回标识符值
怎么实现
Create procedure Insertproduct
@pa varchar(10) ,…………
我要用存储过程插入一条记录但有一列是IDENTITY
现在我要用带返回标识符值
怎么实现
Create procedure Insertproduct
@pa varchar(10) ,…………
Create procedure Insertproduct
@pa varchar(10) ,…………
as
insert into table1 values(......)
return @@identity
go
-------------------建立测试数据------------------------ if object_id('[Admin]') is not null drop table [Admin] go create table [Admin](id int identity(1,1) primary key, AdminType varchar(10), Adminname varchar(10), AdminPassword varchar(10)) go --------------------存储过程开始-------------------------- if object_id('InsertAdmin','P') is not null drop proc InsertAdmin go
create proc InsertAdmin @AdminType varchar(10), @Adminname varchar(10), @AdminPassword varchar(10) as begin --declare @sql varchar(1000) insert into [Admin](AdminType,Adminname,Adminpassword) values (''+@AdminType+'',''+@Adminname+'',''+@AdminPassword+'') end
go
exec InsertAdmin '管理员','admin','admin'
select * from [Admin] --------------------结果----------------------------