1、以数据库text为例:
创新互联-专业网站定制、快速模板网站建设、高性价比天水网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式天水网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖天水地区。费用合理售后完善,10多年实体公司更值得信赖。
USE text
go
SELECT ?A.NAME,MaxRows = MAX(B.rows)
FROM sys.tables A
INNER JOIN sys.partitions B?ON A.object_id = B.object_id
GROUP BY A.name
ORDER BY MAX(B.rows) DESC?- -按数据行数的降序进行排序显示
2、显示所有空表
USE text
go
SELECT ?A.NAME,MaxRows = MAX(B.rows)
FROM sys.tables A
INNER JOIN sys.partitions B?ON A.object_id = B.object_id
GROUP BY A.name
HAVING MAX(B.rows) = 0
3、显示所有非空表
USE text
go
SELECT ?A.NAME,MaxRows = MAX(B.rows)
FROM sys.tables A
INNER JOIN sys.partitions B?ON A.object_id = B.object_id
GROUP BY A.name
HAVING MAX(B.rows) 0
在现有的学生表对姓名的字段进行非空约束,可以先update学生表的姓名字段为null,再通过alter才触发器设置姓名字段为非空not null。这样操作就可以把现有的学生表中姓名字段设置为非空值约束了。
空值数据: select count(*) from YourTable where YourColumnName is null
非空值数据: select count(*) from YourTable where YourColumnName is not null
sqlserver Oracle Access 都通用的!
create trigger DataProarea on testtable
for insert as
if exists(select * from inserted where TestFileds is null)
BEGIN
PRINT 'TestFileds是空值!'
ROLLBACK TRANSACTION
END
ELSE if not exists(select * from inserted join peopletable on inserted.TestFileds=peopletable.Peoplefileds)
begin
PRINT 'TestFileds的值在peopletable表的Peoplefileds中不存在!'
ROLLBACK TRANSACTION
end
GO