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分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注