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.
精彩评论