这个存储过程出错那里???????我看了半天都没有找到 郁闷!!!!!!!!!!!!

悔说话的哑巴 2009-06-10 03:34:17
declare @sumje decimal(12,2)

declare @sDish_c varchar(20)

declare @sDishSet_c varchar(20)

declare curmonth cursor

for select sDish_c,sDishSet_c from #month

open curmonth

FETCH NEXT FROM curmonth

INTO @sDish_c,@sDishSet_c

WHILE (@@FETCH_STATUS = 0)

BEGIN


select sDish_c into #sdish from Cysy_nDoc (nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,7)=@month
and @side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus<>'X'

set @sumje=0
set @sumje=(select count(sDish_c) from Cysy_nDoc(nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,7)=@month
and side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus<>'X')

--select count(sDish_c) from Cysy_nDoc where sDish_c='01001' and substring(sDoc_c,0,9)='20081108'

--累计份数

update #month set sumTotal=@sumje

where sDish_c=@sDish_c


update #month

set a1=(select count(sDish_c) from #sdish (nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,9)=@month+'01'
and side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus<>'X')

where sDish_c=@sDish_c
这个是部分代码
错误提示是消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'sDoc_c' 无效。
消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'side' 无效。
消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'sTrade_c' 无效。
消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'sTrade_c' 无效。
消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'nStatus' 无效。
我明明定义了怎么会错???
...全文
43 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
悔说话的哑巴 2009-06-11
  • 打赏
  • 举报
回复
梁哥,水哥,苦行僧、鼠哥等等帮哈忙啊
悔说话的哑巴 2009-06-11
  • 打赏
  • 举报
回复
[Quote=引用 20 楼 qianjin036a 的回复:]
select sDish_c into #sdish from dbo.Cysy_nDoc (nolock) where sDish_
下一句同样要添加.
[/Quote]
那一句,可以说明白点吗?
claro 2009-06-11
  • 打赏
  • 举报
回复
帮顶
悔说话的哑巴 2009-06-11
  • 打赏
  • 举报
回复
[Quote=引用 24 楼 xuejie09242 的回复:]
SQL code
select sDish_c into #sdish from Cysy_nDoc (nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,7)=@month
and @side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus <>'X'

--上面 是你写的插入临时表的语句
--再看下面:用select出来的表中只有一列,而下面的语句你要查好多列,所以错误

set a1=(select count(sDish_c) from #sdish (nolock) where sDish_c=@sDish_c a…
[/Quote]
可以怎么修改?
悔说话的哑巴 2009-06-11
  • 打赏
  • 举报
回复
呵呵 没有注意 谢谢,我先弄一下
xuejie09242 2009-06-11
  • 打赏
  • 举报
回复

select sDish_c into #sdish from Cysy_nDoc (nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,7)=@month
and @side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus <>'X'

--上面 是你写的插入临时表的语句
--再看下面:用select出来的表中只有一列,而下面的语句你要查好多列,所以错误

set a1=(select count(sDish_c) from #sdish (nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,9)=@month+'01'
and side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus <>'X')


-晴天 2009-06-10
  • 打赏
  • 举报
回复
select sDish_c into #sdish from dbo.Cysy_nDoc (nolock) where sDish_
下一句同样要添加.
悔说话的哑巴 2009-06-10
  • 打赏
  • 举报
回复
坐等牛人啊
悔说话的哑巴 2009-06-10
  • 打赏
  • 举报
回复
随便在问一下,怎么我申请的传相片的哪个怎么都现在都没有给开通?
悔说话的哑巴 2009-06-10
  • 打赏
  • 举报
回复
看了半天,眼睛都看痛了。牛人们来帮帮小弟忙啊
ai_li7758521 2009-06-10
  • 打赏
  • 举报
回复
代码太长了,看不懂。

估计错误和你的别名引用有关。

SQL Select语句完整的执行顺序: 
1、from子句组装来自不同数据源的数据;
2、where子句基于指定的条件对记录行进行筛选;
3、group by子句将数据划分为多个分组;
4、使用聚集函数进行计算;
5、使用having子句筛选分组;
6、计算所有的表达式;
7、使用order by对结果集进行排序。


(8) SELECT (9) DISTINCT (11) <TOP_specification> <select_list>
(1) FROM <left_table>
(3) <join_type> JOIN <right_table>
(2) ON <join_condition>
(4) WHERE <where_condition>
(5) GROUP BY <group_by_list>
(6) WITH {CUBE | ROLLUP}
(7) HAVING <having_condition>
(10) ORDER BY <order_by_list>
悔说话的哑巴 2009-06-10
  • 打赏
  • 举报
回复
哎,哪个没有问题啊
jiujiang88 2009-06-10
  • 打赏
  • 举报
回复
select sDish_c into #sdish from Cysy_nDoc (nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,7)=@month
and side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus <>'X'
错误提示是消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'sDoc_c' 无效。
消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'side' 无效。
消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'sTrade_c' 无效。
消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'sTrade_c' 无效。
消息 207,级别 16,状态 1,过程 usp_Cysy_getsDish_CMonthCountB,第 199 行
列名 'nStatus' 无效。
这些列在Cysy_nDoc是否存在,你需要检查一下。

悔说话的哑巴 2009-06-10
  • 打赏
  • 举报
回复
因为太在长所以没有贴完
悔说话的哑巴 2009-06-10
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 fengbohn 的回复:]
create proc pro_temp

as

begin

declare @sumje decimal(12,2)

declare @sDish_c varchar(20)

declare @sDishSet_c varchar(20)

declare @month varchar(20)

declare @side varchar(20)

declare @sTrade_ce varchar(20)

declare @sTrade_cb varchar(20)

declare @sDish_ varchar(20)

declare curmonth cursor



for select sDish_c,sDishSet_c from #month

open curmo…
[/Quote]
你直接说你改的那里?
JonasFeng 2009-06-10
  • 打赏
  • 举报
回复
楼主查下
FROM 之后的表
前面的字段跟后面的表不匹配!
--小F-- 2009-06-10
  • 打赏
  • 举报
回复
我是来学习的
drysea 2009-06-10
  • 打赏
  • 举报
回复
是不是临时表#sdish没有了?
冯修远 2009-06-10
  • 打赏
  • 举报
回复
create proc pro_temp

as

begin

declare @sumje decimal(12,2)

declare @sDish_c varchar(20)

declare @sDishSet_c varchar(20)

declare @month varchar(20)

declare @side varchar(20)

declare @sTrade_ce varchar(20)

declare @sTrade_cb varchar(20)

declare @sDish_ varchar(20)

declare curmonth cursor



for select sDish_c,sDishSet_c from #month

open curmonth

FETCH NEXT FROM curmonth

INTO @sDish_c,@sDishSet_c

WHILE (@@FETCH_STATUS = 0)

BEGIN


select sDish_c into #sdish from Cysy_nDoc (nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,7)=@month
and @side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus <>'X'

set @sumje=0
set @sumje=(select count(sDish_c) from Cysy_nDoc(nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,7)=@month
and side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus <>'X')

--select count(sDish_c) from Cysy_nDoc where sDish_c='01001' and substring(sDoc_c,0,9)='20081108'

--累计份数

update #month set sumTotal=@sumje

where sDish_c=@sDish_c


update #month

set a1=(select count(sDish_c) from #sdish (nolock) where sDish_c=@sDish_c and substring(sDoc_c,0,9)=@month+'01'
and side=@sIde and sTrade_c between @sTrade_cb and @sTrade_ce and nStatus <>'X') where sDish_c=@sDish_

end
end
go
好象是有很多变量没有定义,也没仔细看你里面的细节,帮你把语法错误都改了,你可以参考下
悔说话的哑巴 2009-06-10
  • 打赏
  • 举报
回复
fetch next from curmonth

INTO @sDish_c,@sDishSet_c



end





CLOSE curmonth

DEALLOCATE curmonth


加载更多回复(6)

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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