sqlserver 2008常用sql语句总结

sqlserver 2008常用sql语句总结
1.查询某个数据库有多少个表
select count(*)
from sys.tables as t, sysindexes as i
where t.object_id = i.id and i.indid <=1

2.查询某个数据库的所有表的行数记录

select schema_name(t.schema_id) as [Schema], t.name as TableName,i.rows as [RowCount]
from sys.tables as t, sysindexes as i
where t.object_id = i.id and i.indid <=1 order by tableName asc

3.查询某个表的行数记录
select COUNT(*) from dbo.Users;

查某个表的字段数量

select?count(*)?from?syscolumns?where?id?=?object_id('表名')
?违法primary key 约束解决方法
sqlserver 2008常用sql语句总结
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Scroll to top
0
Would love your thoughts, please comment.x
()
x