22,210
社区成员
发帖
与我相关
我的任务
分享
declare @v;
EXEC(
'select top '
+
(if @v = 1 '1' else '10')
+
' * from appointment'
)
declare @v INT,@sql VARCHAR(max);
SET @sql='select top '
+
(CASE WHEN @v = 1 THEN '1' else '10' END)
+
' * from appointment'
EXEC(
@sql
)
int QSqlQuery::size() const
Returns the size of the result (number of rows returned), or -1 if the size cannot be determined or if the database does not support reporting information about query sizes. Note that for non-SELECT statements (isSelect() returns false), size() will return -1. If the query is not active (isActive() returns false), -1 is returned.
数据库不支持返回行数,Qt也没办法。
建议用next()遍历数据集。
如果实在想知道多少行,那就查count呗。