I'm creating a script to automatically configure 2 databases for mirroring, using this how to but I want to make sure there is no end point or master key already created so I would like to first do some clean up as:
DROP ENDPOINT End_Mirroring;
DROP CERTIFICATE PRIM_cert;
DROP MASTER KEY
But how can I do these drops only if they already exist?(i need this to avoid my script to exit with error)