见鬼了,T-SQL简单的if else错误。

duhongbo88 2008-03-05 03:52:44


declare @TempID int
declare @dlpl_dailiID int

SELECT @TempID = count(1) FROM ny_daili WHERE dl_mima=@dl_mima
IF @TempID = 0

begin
INSERT INTO ny_daili(
xxx
)VALUES(
@xxx
)
Set @dlpl_dailiID = @@IDENTITY
end


declare @i int
select @i=1
while @i<=49

begin
INSERT INTO ny_dailipeilv(
[dlpl_dailiID],[dlpl_leibie],[dlpl_mingcheng],[dlpl_peilv]
)VALUES(
@dlpl_dailiID,'斑级',@i,'41'
)
set @i=@i+1
end

select @dlpl_dailiID

ELSE -----报ELSE附近有错误或ELSE本身错误

select 0

...全文
52 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
dawugui 2008-03-05
declare @TempID int
declare @dlpl_dailiID int

SELECT @TempID = count(1) FROM ny_daili WHERE dl_mima=@dl_mima
IF @TempID = 0
begin
begin
INSERT INTO ny_daili(
xxx
)VALUES(
@xxx
)
Set @dlpl_dailiID = @@IDENTITY
end

declare @i int
select @i=1
while @i<=49

begin
INSERT INTO ny_dailipeilv(
[dlpl_dailiID],[dlpl_leibie],[dlpl_mingcheng],[dlpl_peilv]
)VALUES(
@dlpl_dailiID,'斑级',@i,'41'
)
set @i=@i+1
end

select @dlpl_dailiID
end
ELSE -----报ELSE附近有错误或ELSE本身错误
begin
............
end

select 0


回复
pt1314917 2008-03-05

declare @TempID int
declare @dlpl_dailiID int

SELECT @TempID = count(1) FROM ny_daili WHERE dl_mima=@dl_mima
IF @TempID = 0
begin
INSERT INTO ny_daili(xxx)VALUES(@xxx)
Set @dlpl_dailiID = @@IDENTITY

declare @i int
select @i=1
while @i<=49
begin
INSERT INTO ny_dailipeilv([dlpl_dailiID],[dlpl_leibie],[dlpl_mingcheng],[dlpl_peilv])VALUES(@dlpl_dailiID,'斑级',@i,'41' )
set @i=@i+1
end
select @dlpl_dailiID
end
ELSE
select 0


回复
duhongbo88 2008-03-05
汗,,,,这么简单,郁闷
回复
wzy_love_sly 2008-03-05
select @dlpl_dailiID
写在end里

if
begin
语句
end
别断开
else
begin
语句
end
回复
lhsxsh 2008-03-05
语法错了吧
回复
-狙击手- 2008-03-05
declare @TempID int
declare @dlpl_dailiID int

SELECT @TempID = count(1) FROM ny_daili WHERE dl_mima=@dl_mima
IF @TempID = 0
begin ------------------------------------ADD
begin
INSERT INTO ny_daili(
xxx
)VALUES(
@xxx
)
Set @dlpl_dailiID = @@IDENTITY
end


declare @i int
select @i=1
while @i<=49

begin
INSERT INTO ny_dailipeilv(
[dlpl_dailiID],[dlpl_leibie],[dlpl_mingcheng],[dlpl_peilv]
)VALUES(
@dlpl_dailiID,'斑级',@i,'41'
)
set @i=@i+1
end

select @dlpl_dailiID
end ---------------------------------------ADD
ELSE -----报ELSE附近有错误或ELSE本身错误

select 0
回复
-狙击手- 2008-03-05
declare @TempID int
declare @dlpl_dailiID int

SELECT @TempID = count(1) FROM ny_daili WHERE dl_mima=@dl_mima
IF @TempID = 0
begin ------------------------------------ADD begin
INSERT INTO ny_daili(
xxx
)VALUES(
@xxx
)
Set @dlpl_dailiID = @@IDENTITY
end


declare @i int
select @i=1
while @i<=49

begin
INSERT INTO ny_dailipeilv(
[dlpl_dailiID],[dlpl_leibie],[dlpl_mingcheng],[dlpl_peilv]
)VALUES(
@dlpl_dailiID,'斑级',@i,'41'
)
set @i=@i+1
end

select @dlpl_dailiID
end ---------------------------------------ADD
ELSE -----报ELSE附近有错误或ELSE本身错误

select 0
回复
-狙击手- 2008-03-05
declare @TempID int
declare @dlpl_dailiID int

SELECT @TempID = count(1) FROM ny_daili WHERE dl_mima=@dl_mima
IF @TempID = 0
begin
begin
INSERT INTO ny_daili(
xxx
)VALUES(
@xxx
)
Set @dlpl_dailiID = @@IDENTITY
end


declare @i int
select @i=1
while @i<=49

begin
INSERT INTO ny_dailipeilv(
[dlpl_dailiID],[dlpl_leibie],[dlpl_mingcheng],[dlpl_peilv]
)VALUES(
@dlpl_dailiID,'斑级',@i,'41'
)
set @i=@i+1
end

select @dlpl_dailiID
end
ELSE -----报ELSE附近有错误或ELSE本身错误

select 0

回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2008-03-05 03:52
社区公告
暂无公告