# Re: 请问以下SQL程序有何错误

Posted by 大头 on October 13, 1998 at 16:54:32:

In Reply to: 请问以下SQL程序有何错误 posted by 孤帆 on October 13, 1998 at 14:28:48:

:
: CREATE PROCEDURE UPDATE_TDUTYRCD
: (@d1 char(7),@d2 char(5),@d3 char(5))
: AS
: select employee,sum(hour88) as hour
: into #tday
: from t_transduty
: where convert(char(8),date,112) like @d1
: and type = '5'
: group by employee
:
: select t_dutyrcd.employee,(already + hour) as aa
: into #tday2
: from t_dutyrcd join #tday on t_dutyrcd.employee=#tday.employee
: where date=@d2
:
: update t_dutyrcd set already=aa
: where t_dutyrcd.employee=#tday2.employee
: and t_dutyrcd.date=@d3
:
: RETURN

: GO

: 错误讯息如下:
: ERROR 107:[SQL Server] The coiumn prefix '#tday2' does not match
: with a table name or alias name used in the query.

错在Update 那边.因为你Where 来自于两个档.
所以你少下了 from t_dutyrcd,#tday2
了了吗 ??

Follow Ups: