存储过程基础学习

--创建存储过程
create proc procedureName
--存储过程参数
@Params
as
--执行语句
return
--执行存储过程
go
--变量的申明
declare @param int
--变量的赋值 赋值是前面必须加set
set @param=32
--申明多个变量
declare @s varchar(23),@a int
--sql 里面的if语句
if
--条件
begin
--执行语句
end
else begin
--执行语句
end

declare @d int
set @d=233
if @d=233 begin
--打印
print '正确'
end
else begin
print '错误'
end
--sql 里的多条件选择语句
declare @contion int,@test varchar(32)
set @contion=12
select @contion
case
when @test='一' then 1
when @test='二' then 2
when @test='三' then 3
else 100
end

--循环语句
while --条件
begin
--执行语句
end


declare @t int
set @t=1
while @t<1000 begin
set @t=@t
end
--打印
print @t

--truncate table author 删除
--从查询的结果中创建一个新表
--select into newTable
select * into newTables from Uname


--insert into select
--把Uname里面的字段Username赋值到ABC
--ABC 表必须存在
insert into ABC select UserName from Uname

--创建临时表语法:
create table #temp(
id int identity(1,1) primary key,
name varchar(18),
sex varchar(39)
)
--查询临时表
select *from #temp


---存储过程
--要创建存储过程的shjuuk
Use NETGPSDB4
--判断要创建的存储过程是否存在
if Exists(select name from systemobj where name='vehiclebyUserid' and type='p')
--删除存储过程
drop proc vehiclebyUserid
go
--创建存储过程
create proc vehiclebyUserId
--存储过程参数
declare @temp1 int
declare @temp2 varchar(12)
declare @temp3 varchar(32)
as
--执行存储过程函数体
insert into Uname(age,names,sex) values(@temp1,@temp2,@temp3)
return
--执行
go
--执行存储过程
exec vehiclebuUserid 12,'ad','男'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值