日期:2014-05-18  浏览次数:20522 次

数据复制问题 ___我是菜鸟
CREATE   PROCEDURE   [dbo].[Pr_XItem_Copy](@intXYNumOne   INT=0,@intXYNumTwo   INT=0)
WITH   RECOMPILE
AS
declare   @intXINumOne   INT;
declare   @intXINumTwo   INT;
delete   from   dbo.XItem   where   XYNum   =   @intXYNumTwo;
insert   into   dbo.XItem(XYNum,XINO,XItem,XIType,XIright)  
select   @intXYNumTwo,XINO,XItem,XIType,XIright  
from   dbo.XItem  
where   XYNum   =   @intXYNumOne;
while   select   @intXINumOne   =   XINum   from   dbo.XItem   where   XYNum   =   @intXYNumOne
begin
select   @intXINumTwo   =XINum
from   dbo.XItem  
where   XYNum   =   @intXYNumTwo  
and   XItem   =(select   XItem  
from   dbo.XItem  
where   XYNum   =   @intXYNumOne
and   XINum   =   case   when   dbo.XItem(@intXINumOne));
insert   into   dbo.XContent(XINum,XCNO,XContent,XCLevel)  
select   @intXINumTwo,XCNO,XContent,XCLevel   from   dbo.XContent
where   XINum   =   @intXINumOne;
end;
GO

------解决方案--------------------
case when????????
------解决方案--------------------
case when dbo.XItem(@intXINumOne)

问题在这里。。。
搂主想实现什么?
------解决方案--------------------
while select @intXINumOne = XINum from dbo.XItem where XYNum = @intXYNumOne
===>
while exists(select 1 from dbo.XItem where XYNum = @intXYNumOne)
------解决方案--------------------
case when dbo.XItem(@intXINumOne)); 这有问题
完整的写法
case '某某 ' when '某某 ' then '某某 ' else '某某 ' end
------解决方案--------------------
while exists(select @intXINumOne = XINum from dbo.XItem where XYNum = @intXYNumOne)
while exists--加上这个
------解决方案--------------------
CREATE PROCEDURE [dbo].[Pr_XItem_Copy](@intXYNumOne INT=0,@intXYNumTwo INT=0)
WITH RECOMPILE
AS
declare @intXINumOne INT
declare @intXINumTwo INT;
delete from dbo.XItem where XYNum = @intXYNumTwo;
insert into dbo.XItem(XYNum,XINO,XItem,XIType,XIright)
select @intXYNumTwo,XINO,XItem,XIType,XIright
from dbo.XItem
where XYNum = @intXYNumOne;
while exists(select 1 from dbo.XItem where XYNum = @intXYNumOne)
begin
select @intXINumTwo =XINum
from dbo.XItem
where XYNum = @intXYNumTwo
and XItem =(select XItem
from dbo.XItem
where XYNum = @intXYNumOne
and XINum = @intXINumOne)
insert into dbo.XContent(XINum,XCNO,XContent,XCLevel)
select @intXINumTwo,XCNO,XContent,XCLevel from dbo.XContent
where XINum = @intXINumOne
end
GO

------解决方案--------------------
那么多,看不下去了.
帮你up 下.
------解决方案--------------------
up