SqlServer常用语法
在此记录常用语法,以免遗忘
SqlServer2012 以下版本分页
-- 从第九条记录之后 查询5条记录(不含第9条) select top 5 * from table(nolock) where id not in (select top 9 id from table(nolock))
// MyBatis下的用法 // 错误示例 String sql = "select top #{page} * from table(nolock) where id not in (select top #{startNum} id from table(nolock))"; // 可行示例 String sql = "select top ${page} * from table(nolock) where id not in (select top ${startNum} id from table(nolock))"; String sql = "select top " + page + " * from table(nolock) where id not in (select top " + startNum + " id from table(nolock))";
查看存储过程
sp_helptext 对象名