- SQL code
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER proc [dbo].[proc_new]@id int=0,@mun int=100asselect top @num * from employee where id>@idGOSET ANSI_NULLS OFFGOSET QUOTED_IDENTIFIER OFFGO-----------------------------------error:消息 102,级别 15,状态 1,过程 proc_newproc,第 5 行[email protected]' 附近有语法错误。
------解决方案--------------------
- SQL code
--加个括号试试哟select top (@num) * from employee where id>@id
------解决方案--------------------
- SQL code
ALTER proc [dbo].[proc_new]@id int=0,@num int=100 --变量名定义错了asselect top (@num) * from employee where id>@id --加括号GO
------解决方案--------------------
2005中top支持参数
select top (@num) * from employee where id>@id
2000的话需要拼接成动态sql以后执行
exec ('sekect top '+cast(@num as varchar(10))+' * from employee where id>'+cast(@id as varchar(10)))
------解决方案--------------------
- SQL code
2005的话select top (@num) * from employee where id>@id2000的话exec ('sekect top '+ltrim(@num)+' * from employee where id>'+ltrim(@id)'