没有测试: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
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+''''
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
哎呀,又出错了,我的pro_count定义的时候就是int 类型的阿
sqlserver自带的帮助,是最好的语法书。
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+'''')
'update ys_shop set counts='+@procount+' where ys_name ='+''''+@pro_names+'''' ==》 update ys_shop set counts='+@procount+' where ys_name ='''+@pro_names+''''
@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
这句修改一下
select @SQL ='update ys_shop set counts=11 where ys_name ='+''''+@pro_names+''''
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
exec sp_executesql @SQL
==》
exec('update ys_shop set counts=11 where ys_name ='''+@pro_names+'''')
==》
update ys_shop set counts='+@procount+' where ys_name ='''+@pro_names+''''