开发者

sql server function that indicates if previous query returns results

Is there a function in TSql that indicates wh开发者_开发技巧ether the previous query returned any results.


Try @@rowcount:

--# your query goes here

if @@rowcount > 0 or rowcount_big() > 0
begin
  --# query returned something
end


It would be helpful if you stated what you are trying to accomplish. Are you thinking about queries within the same connection or in the same batch or last query run on the server? Are you referring to queries within a single database? There is a variable @@rowcount that has the number of rows of the last command executed, that is a likely candidate, but it depends on the context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜