/*学生信息临时表增加原班级id字段*/
if not exists (select 1
from sysobjects a,syscolumns b
where a.id = object_id('tmp_student_info') and
a.id = b.id and
b.name = 'old_classid')
alter table tmp_student_info
add old_classid uniqueidentifier null
go
这段SQL语句先判断数据库中是否有old_classid这个字段,如果没有那么加入这个字段,这个在为程序打数据库补丁包时是很好用的