在 microsoft sql server 2008 中运行查询之前如何知道有多少行会受到影响 [英] how to know how many rows will be affected before running a query in microsoft sql server 2008

查看:30
本文介绍了在 microsoft sql server 2008 中运行查询之前如何知道有多少行会受到影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了一些关于 ROWCOUNT 的内容,但它并不是我正在寻找的内容.根据我的理解,rowcount 表示运行查询后受影响的行数.我正在寻找的是在您运行查询之前知道.这可能吗?

i've read a bit about ROWCOUNT but its not exactly what im looking for. from my understanding rowcount states the number of rows affected AFTER you run the query. what im looking for is knowing BEFORE you run the query. is this possible?

推荐答案

简短的回答是否定的..

Short answer is no..

在执行查询之前,您无法获取行数..至少在 SQL Server 中.

You cannot get the number of rows before executing the query..atleast in SQL server.

最好的方法是使用

Select count(*) from <table> where <condtion>

然后执行您的实际查询

 [delete]or [update] [set col='val']
 from <table> where <condtion>

这篇关于在 microsoft sql server 2008 中运行查询之前如何知道有多少行会受到影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆