1、waitfor 命令是让程序停顿指定的时间在运行或在指定时间运行

waitfor delay '00:00:02' 延迟两秒运行

print (getdate())

waitfor time '12:00:00'到12点再运行

print '放学了'

2、go 批处理执行程序

不用go如果有错误整段代码都执行失败

用gogo之间的代码块独立执行 如果有一段失败提示有误 但是其它代码段依然被执行

批处理循环执行

go

print 'hello'

go 2

3、with

with a as (select * from student)

select * from a 

4 goto 跳转到标签

goto error

print 'here'

error:

print 'imhere'

获取自动增长的主键值

insert into Person(age,Name) values(3,'abc'); select @@identity

insert into Person(age,Name) output inserted.id values(3,'abc')