开发者

sql server function that indicates if previous query returns results

开发者 https://www.devze.com 2023-02-11 16:17 出处:网络
Is there a function in TSql that indicates wh开发者_开发技巧ether the previous query returned any results.Try @@rowcount:

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

精彩评论

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