码迷,mamicode.com
首页 > Web开发 > 详细

MVC存储过程

时间:2018-07-29 23:24:08      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:ima   har   过程   proc   添加   update   arch   arc   HERE   

create table lei
(
lid int identity ,
lname varchar(30)
)
create table biao
(
bid int primary key identity ,
bname varchar(30) ,
age varchar(30) ,
lid int
)


--添加


create proc up_add
(
@bname varchar(30) ,
@age varchar(30) ,
@lid int
)
as
begin
insert into biao values(@bname,@age,@lid)
end

---修改--
create proc up_upt
(
@bid int ,
@bname varchar(30) ,
@age varchar(30) ,
@lid int
)
as
begin
update biao set bname=@bname,age=@age,lid=@lid where bid=@bid
end

----删除
create proc up_del
(
@bid int
)
as
delete from biao where bid=@bid


--查询---
create proc up_cha
@bid varchar(10) ,
@bname varchar(30) ,
@age varchar(30) ,
@lid varchar(10)
as
begin
declare @sqls nvarchar(max)
set @sqls = ‘select * from biao where 1=1‘;
if(@bid!=‘‘)
set @sqls +=‘ and ProductBrandId = ‘‘‘+@bid+‘‘‘‘;
if(@bname!=‘‘)
set @sqls += ‘ and ProductMenId = ‘‘‘+@bname+‘‘‘‘;
if(@age!=‘‘)
set @sqls += ‘ and ProductLuxuryId =‘‘‘+@age+‘‘‘‘;
if(@lid!=‘‘)
set @sqls += ‘ and ProductLuxuryId =‘‘‘+@lid+‘‘‘‘;

exec(@sqls)
end
go
exec up_cha ‘‘,‘‘,‘‘,‘‘

MVC存储过程

标签:ima   har   过程   proc   添加   update   arch   arc   HERE   

原文地址:https://www.cnblogs.com/JXSBoKeYuan/p/9388071.html

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