com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误

该错误出现的原因之一可能是使用sql分页部分的问题。

我的项目部分代码

<!--获取所有用户 -->
<select id="getAllUser" parameterType="String" resultType="user">
	select *
	from [addrbook].[dbo].[user]
	<where>
		<if test="truename != null and truename !='' ">
			truename like concat("%",#{truename},"%")
		</if>
	</where>
	<!-- 执行分页查询 -->
	<if test="start != null and rows != null">
		limit #{start},#{rows}
	</if>
</select>

在我的项目中原本是使用mysql数据库,通过mysql中的limit来实现数据库语句分页,现如今我换成了sqlserver,这就导致了这个问题的产生。在sqlserver中实现sql语句分页是不支持limit的,需要通过top或者row_number()来实现。

猜你喜欢

转载自blog.csdn.net/bgyuan_csdn/article/details/88938731