转:http://www.cnblogs.com/pangpanghuan/p/6432331.html Sql Server 增加字段.修改字段.修改类型.修改默认值 1.修改字段名: alter table 表名 rename column A to B 2.修改字段类型: alter table 表名 alter column 字段名 type not null 3.修改字段默认值 alter table 表名 add default (0) for 字段名 with values 如果字…
SQL Server为字段添加默认值 if not exists ( select * from sys.columns as c join sys.objects as o on c.default_object_id = o.[object_id] where c.[object_id] = object_id('DriverTable') and c.name = 'DriverVan' ) begin alter table DriverTable add default(0) for…
SQL SERVER: 合并相关操作(Union,Except,Intersect) use tempdb create table tempTable1 (id int primary key identity, price int) create table tempTable2 (id int primary key identity, price int) select * from temptable1 select * from temptable2 --union会删除重复值,也就…
最近帮一个客户搭建跨洋的合并复制,由于数据库非常大,跨洋网络条件不稳定,因此只能通过备份初始化,在初始化完成后向海外订阅端插入数据时发现报出如下错误: Msg 548, Level 16, State 2, Line 2 The insert failed. It conflicted with an identity range check constraint in database %s, replicated table %s, column %s. If the identit…
SQL Server 中对于结果集有几个处理,值得讲解一下 1. 并集(union,Union all) 这个很简单,是把两个结果集水平合并起来.例如 SELECT * FROM A UNION SELECT * FROM B [注意]union会删除重复值,也就是说A或B中重复的数据行,最终只会出现一次,而union all则会保留重复行. 2. 差异(Except) 就是两个集中不重复的部分.例如 SELECT * FROM A EXCEPT SELECT * FROM B 这个的意思是,凡…