存储过程语法以下:html
CREATE PROC [ EDURE ] procedure_name [ ; number ]
sql
[ { @parameter data_type }
[ VARYING ] [ =
default
] [ OUTPUT ]
] [ ,...n ]
[ WITH
{ RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]
[ FOR REPLICATION ]
AS
sql_statement [ ...n ]
Create PROCEDURE WeekDay
as函数
--下面sql为sql_statement
begin
Declare
@week nvarchar(20),
@today intspa
begin
set @today=3
set @week=case
when @today=1 then '星期一'
when @today=2 then '星期二'
when @today=3 then '星期三'
when @today=4 then '星期四'
when @today=5 then '星期五'
when @today=6 then '星期六'
when @today=7 then '星期日'
else '值错误'
end
print @week
end
end3d
二、执行存储过程code
exec WeekDayhtm
经常使用sql语句:1)if语句blog
2)多条件选择语句string
3)循环语句 io
4)游标
select
@user1=
'张三';select
@user2 =
Name
from
ST_User
where
ID=1 3)update
ST_User
set
@user3 =
Name
where
ID=1
