I'm creating a script to recreate a database for test purposes, and the database has some publications. In order to create or not the logreader agent I need to know if the current database already has one, or destroy the existing agent prior to recreate the database. I know there is some class in SMO can do that, but I need to achieve the same with T-SQL. Someone can help?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
Here's how it works:
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Below T-SQL will give you the log reader agent. You can use the agent name or job_id to drop/delete the log reader agent.