SQL语句简单记录

SQL SERVER

新增列与默认值

alter table 表名 add 列明 bit default 0 not null

删除列(容易删除失败)

alter table 表名 drop column 列名

Intersect 获取两个表的交集

SELECT * FROM tableA
INTERSECT
SELECT * FROM tableB

EXCEPT获取俩个表的差集

SELECT * FROM tableA
EXCEPT
SELECT * FROM tableB

 SQLServer快速获取表行数

select  a.name as '表名',b.rows as '表数据行数'
from sysobjects a inner join sysindexes b
on a.id = b.id
where   a.type = 'u'
and b.indid in (0,1)
--and a.name = 't%'
order by b.rows DESC

 

posted @ 2014-08-14 09:56  泥称  阅读(115)  评论(0编辑  收藏  举报