3、存在141.if exists (select * from syscolumns where id=object_id('PartStock') and name='PartVelocity') 2.print 'PartVelocity exists' 3.else print 'PartVelocity not exists' 另法:判断表的存在性:1.select count(*) from sysobjects where type='U' and name='你的表名' 判断字段的存在性:1.select count(*) from syscolumns 2.where
4、 id 3.= (select id from sysobjects where type='U' and name='你的表名') 4.and name = '你要判断的字段名' 7.随机读取若干条记录Access语法:SELECTtop10*From表名ORDERBYRnd(id)Sqlserver:selecttopn*from表名orderbynewid()mysql:select*From表名OrderByrand()Limitn8.说明:日程安排提前五分钟提醒select*from日程安排wheredatediff(minute,f开始时间,getdate())>59.前
6、nswhereid=object_id(TableName)14.说明:列示type、vender、pcs字段,以type字段排列,case可以方便地实现多重选择,类似select中的case。1.select type,sum(case vender when A then pcs else 0 end),sum(case vender when C then pcs else 0 end), 2.sum(case vender when B then pcs else 0 end) FROM tablename group by type 15.说明:初始化表table1TRUN