if object_id('test')is not null drop table test go create table test(ID int identity(1,1),Sex varchar(2) check(sex in('男','女'))) begin tran insert test select '男' if @@error=0 begin commit raiserror('插入成功',16,1) end else rollback go select * from test /*(所影响的行数为 1 行)服务器: 消息 50000,级别 16,状态 1,行 7 插入成功 ID Sex ----------- ---- 1 男(所影响的行数为 1 行)*/
go
create table test(ID int identity(1,1),Sex varchar(2) check(sex in('男','女')))
begin tran
insert test select '男'
if @@error=0
begin
commit
raiserror('插入成功',16,1)
end
else
rollback
go
select * from test
/*(所影响的行数为 1 行)服务器: 消息 50000,级别 16,状态 1,行 7
插入成功
ID Sex
----------- ----
1 男(所影响的行数为 1 行)*/
a用户登录系统,然后他要插入一条数据,数据库执行完毕后会返回一条插入成功(消息m)吧?应该是返回给这个用户的。
b用户登录系统,执行查询,数据库接收到指令查到数据(数据n)要返回给b。把执行的结果返回给客户端,数据库就会知道到底返回给谁吧(消息m返回给a,数据n返回给b。不会出现消息m给了b。。数据n给了a的情况吧?)???不用人来控制。