--判断是否存在myProc这个存储过程
If not exists (select * from dbo.sysObjects where id = Object_Id(N'myProc')
and ObjectProperty(id, N'IsProcedure') = 1)
BEGIN
导出来的创建myProc这个存储过程的脚本
END
其他的类似这样:
[code=sql]
判断myTalbe对象是否是一个表。
If exists (select * from dbo.sysObjects where id = Object_Id(N'myTable') and ObjectProperty(id, N'IsUserTable') = 1)
判断myProc对象是否是一个存储过程。
If exists (select * from dbo.sysObjects where id = Object_Id(N'myProc') and ObjectProperty(id, N'IsProcedure') = 1)
判断myFun对象是否是一个自定义、标量值函数。
If exists (select * from dbo.sysObjects where id = Object_Id(N'myFun') and ObjectProperty(id, N'IsScalarFunction') = 1)
判断myFun对象是否是一个表值函数。
If exists (select * from dbo.sysObjects where id = Object_Id(N'myFun') and ObjectProperty(id, N'IsTableFunction') = 1)