sql server
CREATE procedure dt_tt
as
declare @xx int
set @xx=-1
select @xx=id from test where getdate() between kc and js
select @xx
GO
asa和上面相同功能的语句
CREATE procedure dt_tt
begin
declare @xx int
set @xx=-1
select @xx=id from test where getdate() between kc and js
select @xx
end
没有记录查询到
sql server 结果 -1
asa null
返回记录集来说:
sql server :
select 语句
select 赋值语句除外
asa
select
如果用 select @xx=id 这将返回记录集 @xx列
有些sql 里的条件语句可能用在 if 语句中
is null is not null xx in ()
sql server 中没有多分支语句,sql 语句中可以用case
asa 有多分支语句
事务处理:(自动开始事务)
asa transcount =0 sql transcount=1
CREATE procedure dt_tt
as
declare @xx int
set @xx=-1
select @xx=id from test where getdate() between kc and js
select @xx
GO
asa和上面相同功能的语句
CREATE procedure dt_tt
begin
declare @xx int
set @xx=-1
select @xx=id from test where getdate() between kc and js
select @xx
end
没有记录查询到
sql server 结果 -1
asa null
**后来经重新测试 asa返回结果也是-1
返回记录集来说:
sql server :
select 语句
select 赋值语句除外
asa
select
如果用 select @xx=id 这将返回记录集 @xx列
有些sql 里的条件语句可能用在 if 语句中
is null is not null xx in ()
sql server 中没有多分支语句,sql 语句中可以用case
asa 有多分支语句
事务处理:(自动开始事务)
asa transcount =0 sql transcount=1
sql server 赋值语句
select @id=id from table
asa
select id into @id from table
select @id=id from table ( 也支持) //有时在触发器中不好用不知道为什么换成上面的就行了
在watcom-sql标准中,要使用分号,if 语句要在end if 后面加';'号
并且赋值语句为
select colname into @var from table
为transact-sql
select @var=colname from table
不要加分号
注意支持的语句格式如
w_sql if end if;
transact-sql if begin end
本文介绍 SQL Server 中存储过程的创建方法及使用技巧,对比了不同语法风格的特点,并探讨了条件语句、多分支选择及事务处理等内容。
1363

被折叠的 条评论
为什么被折叠?



