码迷,mamicode.com
首页 > 数据库 > 详细

sql的存储

时间:2020-07-10 09:38:16      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:begin   rop   use   creat   ack   var   value   exec   tran   

create database ZuoYe
use ZuoYe

select * from OrderInfoes
select * from Goods
select * from Shops
select c.Id,c.ShopId,c.UserId,g.Name,g.Img,g.Price,s.SName from CollectShops c
join Goods g on c.ShopId=g.ShopId
join Shops s on g.ShopId=s.Id where c.UserId=1


--退款存储过程
alter proc p_drop
(
@Reason varchar(max),
@Img varchar(max),
@Count int,
@GId int,
@UId int,
@Code int out
)
as
begin
begin try
begin tran
insert into DropOrders values (@Reason,@Img,@Count,@GId,@UId)
delete from OrderInfoes where GoodsId=@GId
update Goods set Count+=@Count where Id=@GId
commit tran
set @Code=1
end try
begin catch
rollback tran
end catch
end

declare @res int
exec p_drop ‘‘,‘‘,2,1,1,@res
select @res

sql的存储

标签:begin   rop   use   creat   ack   var   value   exec   tran   

原文地址:https://www.cnblogs.com/XiaoyvYa/p/13277423.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!