CREATE    TRIGGER [e_del_subscribe_send_log] ON [dbo].[e_send_log] 
FOR DELETE
AS
declare @esl_id varchar(100)
Select @esl_id =esl_id From deleted
/*
delete each country subscripion Queue user table
*/
if object_id('e_subscribe_send_log_'+@esl_id) is not null
exec('drop TABLE [dbo].[e_subscribe_send_log_'+@esl_id+']')

解决方案 »

  1.   

    if exists(select name from sysobjects where id=object_id('tablename') and xtype='u')
    print 'exist'
      

  2.   

    if exists(select name from sysobjects where id=object_Id('tablename') )
      

  3.   

    CREATE    TRIGGER [e_del_subscribe_send_log] ON [dbo].[e_send_log] 
    FOR DELETE
    AS
    declare @esl_id varchar(100)
    Select @esl_id =esl_id From deleted
    /*
    delete each country subscripion Queue user table
    */if exists (select * from dbo.sysobjects where id = object_id(N'[e_subscribe_send_log_'+@esl_id+']') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    exec('drop table [dbo].[e_subscribe_send_log_'+@esl_id+']')GO
      

  4.   

    CREATE    TRIGGER [e_del_subscribe_send_log] ON [dbo].[e_send_log] 
    FOR DELETE
    AS
    declare @esl_id varchar(100)
    Select @esl_id =esl_id From deleted
    /*
    delete each country subscripion Queue user table
    */
    if objectproperty(object_id(@esl_id),'IsUserTable')=1
      exec('drop TABLE [dbo].[e_subscribe_send_log_'+@esl_id+']')