【【【【【【 存储过程结构问题 libin_ftsafe(子陌红尘)等高人请进 谢谢】】】】】】

噯卟釋手 2004-12-16 04:44:12
我想实现这样的效果 但是有语法错误 呵呵 @type 是存储过程的参数

create proc_test @type varchar(20)
as
begin
if @type = '0'
(if exists(....)
select .....from ... where ...)

if @type = '1'
(if exists(....)
select .....from ... where ...)

if @type = '2'
(if exists(....)
select .....from ... where ...)
end
go


...全文
104 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
vinsonshen 2004-12-16
  • 打赏
  • 举报
回复
改成这样试试:

create proc proc_test @type varchar(20)
as
begin
if @type = '0'
begin
(if exists(....)
select .....from ... where ...
else
select .....from ... where ...)
end
else if @type = '1'
begin
(if exists(....)
select .....from ... where ...
else
select .....from ... where ...)
end
else if @type = '2'
begin
(if exists(....)
select .....from ... where ...
else
select .....from ... where ...)
end
end
噯卟釋手 2004-12-16
  • 打赏
  • 举报
回复
谢谢 谢谢~~~~~~~~~~~~~~~~~~


给分啦
子陌红尘 2004-12-16
  • 打赏
  • 举报
回复
create proc proc_test @type varchar(20)
as
begin

if @type = '0'
begin
if exists(....)
select .....from ... where ...
else
select .....from ... where ...
end

if @type = '1'
begin
if exists(....)
select .....from ... where ...
else
select .....from ... where ...
end

if @type = '2'
begin
if exists(....)
select .....from ... where ...
else
select .....from ... where ...
end

end
go
噯卟釋手 2004-12-16
  • 打赏
  • 举报
回复
晕 我没说清楚
我的结构是这个样子的:

create proc proc_test @type varchar(20)
as
begin
if @type = '0'
(if exists(....)
select .....from ... where ...
else
select .....from ... where ...)

if @type = '1'
(if exists(....)
select .....from ... where ...
else
select .....from ... where ...)

if @type = '2'
(if exists(....)
select .....from ... where ...
else
select .....from ... where ...)
end
go

如何改改?
goregrypeck 2004-12-16
  • 打赏
  • 举报
回复
create procedure proc_test @type varchar(20)
as

if @type = '0'
begin
(if exists(....)
select .....from ... where ...)
end

if @type = '1'
begin
(if exists(....)
select .....from ... where ...)
end
if @type = '2'
begin
(if exists(....)
select .....from ... where ...)
end
go
Andy__Huang 2004-12-16
  • 打赏
  • 举报
回复
create proc proc_test @type varchar(20) --你少了proc
as
set nocount on
set ansi_warnings off

if @type = '0'
begin
if exists(....)
select .....from ... where ...
end
if @type = '1'
begin
if exists(....)
select .....from ... where ...
end

if @type = '2'
begin
if exists(....)
select .....from ... where ...
end

go
NinGoo 2004-12-16
  • 打赏
  • 举报
回复
其余的同意 goregrypeck(派克)
子陌红尘 2004-12-16
  • 打赏
  • 举报
回复
example:

create procedure proc_test @type varchar(20)
as
begin
if (@type = '0')
begin
if exists(select * from myfortune)
select * from myfortune where 1=1
end
if @type = '1'
begin
if exists(select * from myfortune)
select * from myfortune where 1=1
end
if @type = '2'
begin
if exists(select * from myfortune)
select * from myfortune where 1=1
end
end
go
NinGoo 2004-12-16
  • 打赏
  • 举报
回复
create procedure proc_test @type varchar(20)
goregrypeck 2004-12-16
  • 打赏
  • 举报
回复
create proc_test @type varchar(20)
as

if @type = '0'
begin
(if exists(....)
select .....from ... where ...)
end

if @type = '1'
begin
(if exists(....)
select .....from ... where ...)
end
if @type = '2'
begin
(if exists(....)
select .....from ... where ...)
end
go
Liroyal 2004-12-16
  • 打赏
  • 举报
回复
何解?
噯卟釋手 2004-12-16
  • 打赏
  • 举报
回复
何解?

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧