最近准备把以前access做的考勤软件,做到sql里面,结果出现了一个存储过程报错报错提示是:名称'undate 员工表 set 员工表.bc = 员工调整.sz from 员工表 inner join 员工调整 on 员工表.ny = 员工调整.ny and
员工表.xm = 员工调整.xm where 员工表.ny = 1203 and 员工调整.lm = bc' 不是有效的标示符

解决方案 »

  1.   

    具体程序是ALTER PROCEDURE dbo.月考勤前序
    (@ny char(4))
    AS 
    declare @sql varchar(250)
    declare @lm varchar(20)declare c cursor fast_forward for
    select lm from 员工调整 where 员工调整.ny = @ny group by lmopen c
    fetch next from c into @lmwhile @@fetch_status= 0
    begin
    set  @sql = 'update 员工表 set  员工表.' + @lm +' = 员工调整.sz  from 员工表 inner join 员工调整 on 员工表.ny =员工调整.ny 
    and 员工表.xm = 员工调整.xm where 员工表.ny = '+ @ny + ' and 员工调整.lm ='+convert(varchar(10),@lm) 
    exec @sql
    fetch next from c into @lm
    end
    close c
    deallocate c
      

  2.   

    员工调整  列表类型
    ny char(4)
    xm varchar(20)
    lm nvarchar(20)
    sz varchar(50)
    员工表 列表类型
    ny char(4)
    xm varchar(20)
    bc int(4)
    请帮我看看具体是哪里出问题了
    要是能帮我看下如何在优化下,就太感谢了~~=。=
      

  3.   

    try this,ALTER PROCEDURE dbo.月考勤前序
    (@ny char(4))
    AS  
    declare @sql varchar(250)
    declare @lm varchar(20)declare c cursor fast_forward for
    select lm from 员工调整 where 员工调整.ny = @ny group by lmopen c
    fetch next from c into @lmwhile @@fetch_status= 0
    begin
    set @sql = 'update 员工表 set 员工表.' + @lm +' = 员工调整.sz from 员工表 inner join 员工调整 on 员工表.ny =员工调整.ny  
    and 员工表.xm = 员工调整.xm where 员工表.ny = '+ @ny + ' and 员工调整.lm ='+convert(varchar(10),@lm)  
    exec(@sql)
    fetch next from c into @lm
    end
    close c
    deallocate c
      

  4.   

    try this,ALTER PROCEDURE dbo.月考勤前序
    (@ny char(4))
    AS  
    declare @sql varchar(250)
    declare @lm varchar(20)declare c cursor fast_forward for
    select lm from 员工调整 where 员工调整.ny = @ny group by lmopen c
    fetch next from c into @lmwhile @@fetch_status= 0
    begin
    set @sql = 'update 员工表 set 员工表.' + @lm +' = 员工调整.sz from 员工表 inner join 员工调整 on 员工表.ny =员工调整.ny  
    and 员工表.xm = 员工调整.xm where 员工表.ny='''+ @ny + ''' and 员工调整.lm='''+convert(varchar(10),@lm)+''' '
    exec(@sql)
    fetch next from c into @lm
    end
    close c
    deallocate c