• anujkumar.mca - Wednesday, January 3, 2018 6:32 PM

    Dear Folks, 
    I know if condition is commented, because I was trying to put a condition with db state ONLINE, but unfortunately I cant capture the same with the help of below statement select @DBState= state_desc from master.sys.databases where name=@DatabaseName. can someone help me to fix this problem, 
    I just want to create a trigger which can prevent drop database (ONLINE) statement accidentally.

    I don't think you can do it based on querying sys.databases as FridayNightGiant said.
    I think you can only reference what is available in eventdata which would be database name. Or you could just not allow any drops - the trigger would need to be disabled to drop any database.

    Sue