sql判断是否存在函数

if   object_id( 'right')   is   not   null 
        print 'Exist'
        else print 'Not Exist'
GO 
或者

if exists(select name from sysobjects where name='right')
	 print 'Exist'
        else print 'Not Exist'
go
 
object_id()比exists更简洁。


mysql比sql server更简洁:
drop table if exists t_user;
 



猜你喜欢

转载自wandejun1012.iteye.com/blog/1564946