create proc U_SP_DropTable @TableName varchar(50) as begin set nocount on exec ('drop table ' + @TableName) set nocount off end调用:U_SP_DropTable 'test1'
create proc DropTable @Tablename varchar(50) as if exits(select * from sysobjects where name=@tablename and xtype='u') begin drop table @tablename end
CREATE PROCEDURE [aaaaaaaa] @cTableName varchar(40) AS if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[' +@cTableName +']') and OBJECTPROPERTY(id, N'IsUserTable') = 1) exec (' drop table dbo.'+@cTableName )GO
as
begin
set nocount on
exec ('drop table ' + @TableName)
set nocount off
end调用:U_SP_DropTable 'test1'
as
if exits(select * from sysobjects where name=@tablename and xtype='u')
begin
drop table @tablename
end
@cTableName varchar(40)
AS
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[' +@cTableName +']') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
exec (' drop table dbo.'+@cTableName )GO