select @SQL ='update ys_shop  set counts=11   where  ys_name ='''+@pro_names+''' 
" 在TSQL中是对象名界定符,用两个连续的'来表示符串的的一个'

解决方案 »

  1.   

    没有测试:CREATE PROCEDURE order_tot_amt
         @o_id intAS
    declare @pro_names varchar(100)
    declare @procount  int 
    SELECT  @pro_names=pro_name,@procount=pro_count  FROM loogoo_goods
    WHERE order_id=@o_idupdate ys_shop  set counts=11   where  ys_name =@pro_names GO
      

  2.   

    select @SQL ='update ys_shop  set counts=11   where  ys_name ="'+@pro_names+'" ' 
    这句修改一下
    select @SQL ='update ys_shop  set counts=11   where  ys_name ='+''''+@pro_names+'''' 
      

  3.   


    CREATE PROCEDURE order_tot_amt
         @o_id intAS
    declare @pro_names varchar(100)
    declare @procount  int
    declare @SQL nvarchar (2000)
     
    SELECT  @pro_names=pro_name,@procount=pro_count  FROM loogoo_goods
    WHERE order_id=@o_idselect @SQL ='update ys_shop  set counts='+@procount+'   where  ys_name ='+''''+@pro_names+'''' 
    exec sp_executesql @SQL
    GOMicrosoft OLE DB Provider for ODBC Drivers 错误 '80040e07' [Microsoft][ODBC SQL Server Driver][SQL Server]将 varchar 值 'update ys_shop set counts=' 转换为数据类型为 int 的列时发生语法错误。 /shop_ys/sendfriend.asp,行27 
      

  4.   

    哎呀,又出错了,我的pro_count定义的时候就是int 类型的阿
      

  5.   

    sqlserver自带的帮助,是最好的语法书。
      

  6.   

    select @SQL ='update ys_shop  set counts=11   where  ys_name ="'+@pro_names+'" ' 
    exec sp_executesql @SQL
    ==》
    exec('update ys_shop  set counts=11   where  ys_name ='''+@pro_names+'''') 
      

  7.   

    'update ys_shop  set counts='+@procount+'   where  ys_name ='+''''+@pro_names+'''' 
    ==》
    update ys_shop  set counts='+@procount+' where  ys_name ='''+@pro_names+''''