惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
美团技术团队
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
G
Google Developers Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recorded Future
Recorded Future
V
V2EX
Martin Fowler
Martin Fowler
The Last Watchdog
The Last Watchdog
Help Net Security
Help Net Security
S
SegmentFault 最新的问题
W
WeLiveSecurity
L
LINUX DO - 热门话题
C
CERT Recently Published Vulnerability Notes
J
Java Code Geeks
The Cloudflare Blog
AI
AI
NISL@THU
NISL@THU
Schneier on Security
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
V
Vulnerabilities – Threatpost
N
News and Events Feed by Topic
U
Unit 42
P
Proofpoint News Feed
T
The Blog of Author Tim Ferriss
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security Affairs
D
Docker
P
Privacy & Cybersecurity Law Blog
Spread Privacy
Spread Privacy
阮一峰的网络日志
阮一峰的网络日志
B
Blog RSS Feed
SecWiki News
SecWiki News
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
G
GRAHAM CLULEY
S
Schneier on Security
量子位
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美

博客园 - 我想去长安

玩玩 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 构建亿级前端读服务(转贴) - 我想去长安 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 javascript guid(uuid) 用户中心 - 博客园 SQL Server 2012 管理新特性:AlwaysOn【转】 用户中心 - 博客园 SevenArmsSeries.Repositories 用户中心 - 博客园
SQL Server 查询表的记录数(3种方法,推荐第一种)
我想去长安 · 2013-08-02 · via 博客园 - 我想去长安
http://blog.csdn.net/smahorse/article/details/8156483

--SQL Server 查询表的记录数 --one: 使用系统表. SELECT object_name (i.id) TableName, rows as RowCnt FROM sysindexes i INNER JOIN sysObjects o ON (o.id = i.id AND o.xType = 'U ') WHERE indid < 2 ORDER BY TableName --****************** --two: 使用未公开的过程 "sp_MSforeachtable " CREATE TABLE #temp (TableName VARCHAR (255), RowCnt INT) EXEC sp_MSforeachtable 'INSERT INTO #temp SELECT ''?'', COUNT(*) FROM ?' SELECT TableName, RowCnt FROM #temp ORDER BY TableName DROP TABLE #temp --****************** -- three: 使用游标.cursor SET NOCOUNT ON DECLARE @tableName VARCHAR (255), @sql VARCHAR (300) CREATE TABLE #temp (TableName VARCHAR (255), rowCnt INT) DECLARE myCursor CURSOR FAST_FORWARD READ_ONLY FOR SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'base table ' OPEN myCursor FETCH NEXT FROM myCursor INTO @tableName WHILE @@FETCH_STATUS = 0 BEGIN EXEC ( 'INSERT INTO #temp (TableName, rowCnt) SELECT ''' + @tableName + ''' as tableName, count(*) as rowCnt from ' + @tableName) FETCH NEXT FROM myCursor INTO @tableName END SELECT TableName, RowCnt FROM #temp ORDER BY TableName CLOSE myCursor DEALLOCATE myCursor DROP TABLE #temp