cstring format 哪里有错误?

starsky_1 2008-12-12 09:18:13
sql.Format ("SET NOCOUNT ON declare @num int set @num=0 select 线路号, 站点名, 路线=cast('('+线路号+':'+站点名 as varchar(4000)), 序号=序号, tt=@num into # from 线路站点 where 站点名='%s'; while @@rowcount>0 and not exists (select * from # where 站点名='%s') begin set @num=@num+1 insert into #(路线,线路号,站点名,序号,tt) select 路线=a.路线+case when a.线路号=b.线路号 then '->'+b.站点名 else ')转('+b.线路号+':'+b.站点名 end, b.线路号,b.站点名,b.序号,@num from # a, 线路站点 b where a.tt=@num-1 and(a.站点名=b.站点名 and a.线路号<>b.线路号 or a.线路号=b.线路号 and (a.序号=b.序号+1 or a.序号=b.序号-1)) and len(a.路线)<4000 and patindex('%[ >]'+b.站点名+'[-)]%',a.路线)=0 end select '路线'=路线+')' from # where tt=@num and 站点名='%s' if @@rowcount =0 select * from # ;drop table #;",station_start,station_end,station_end);

比较长了点 但不是错误吧?
那到底哪里出错了?
...全文
88 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljhcy99 2008-12-12
  • 打赏
  • 举报
回复
sql.Format ("SET NOCOUNT ON declare @num int set @num=0
select 线路号, 站点名, 路线=cast('('+线路号+':'+站点名 as varchar(4000)),
序号=序号, tt=@num
into #
from 线路站点
where 站点名='%s';
while @@rowcount>0 and not exists (select * from # where 站点名='%s')
begin
set @num=@num+1
//
这一行应该有错误,你的#临时表的结构应该是(线路号, 站点名, 路线,序号,TT),
//
insert into #(路线,线路号,站点名,序号,tt)

select 路线=a.路线+case when a.线路号=b.线路号 then '->'+b.站点名 else ')转('+b.线路号+':'+b.站点名 end,
b.线路号,b.站点名,b.序号,@num
from # a, 线路站点 b
where a.tt=@num-1
and(a.站点名=b.站点名 and a.线路号 <>b.线路号 or a.线路号=b.线路号
and (a.序号=b.序号+1 or a.序号=b.序号-1))
and len(a.路线) <4000
and patindex('%[ >]'+b.站点名+'[-)]%',a.路线)=0
end
select '路线'=路线+')' from #
where tt=@num
and 站点名='%s'
if @@rowcount =0
select * from # ;
drop table #;"
,station_start,station_end,station_end);
starsky_1 2008-12-12
  • 打赏
  • 举报
回复
up

34,838

社区成员

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

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