1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SQL Serverで全テーブルの件数、カラム数を調べる

Posted at

1. はじめに

  • SQL Serverにある全テーブルのレコード件数を調べたい
  • SQL Serverにある全テーブルのカラム件数を調べたい

2. 開発環境

  • SQL Server 2019

3. 全テーブルのレコード数を調べるSQL

SELECT OBJ.name AS TableName, IND.rows
FROM sys.objects AS OBJ
JOIN sys.sysindexes AS IND
ON OBJ.object_id = IND.id AND IND.indid < 2
WHERE OBJ.type = 'U'
ORDER BY OBJ.name;

4. 全テーブルのカラム数を調べるSQL

SELECT O.name As TableName, Count(C.name) As ColumnCount
FROM sys.objects O INNER JOIN sys.columns C ON O.object_id = C.object_id AND O.type = 'U'
GROUP BY O.name

5. 参考文献

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?