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;