Share via

SQL server Email change

Chandra Kumari 21 Reputation points
2021-05-30T08:06:01.077+00:00

Hi , My organization is migrating its email from abc domain to another xyz domain.
So Database team task is to identify all the email operators, db mail operators and change the domains for around 250 SQL server which is in our inventory.

Also, I need to find all the objects( stored procedures etc) where this domain is getting used. So i need to find the query which will give these details. What should be the strategy and planning for this.

Can anyone help with the query and the process we should follow to implement this.

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

Answer accepted by question author

Erland Sommarskog 134.7K Reputation points MVP Volunteer Moderator
2021-05-30T08:27:03.057+00:00

I ran this query in msdb:

SELECT object_name(object_id), name
FROM   sys.columns
WHERE name LIKE '%mail%'

It seems that there are columns in msdb you need to check.

To find references in stored procedures etc in a database, you can run:

SELECT object_name(object_id) 
FROM   sys.sql_modules
WHERE definition LIKE '%abc.com%'

Then the challenge is to run this on all your 250 servers, and on all databases (but the system databases) on every server. If you have not been using Powershell in your daily work, here is an excellent chance to get started!

Was this answer helpful?


3 additional answers

Sort by: Most helpful
  1. Chandra Kumari 21 Reputation points
    2021-05-31T17:07:20.377+00:00

    Hey Thanks for the suggestion.

    Was this answer helpful?

    0 comments No comments

  2. AmeliaGu-MSFT 14,016 Reputation points Microsoft External Staff
    2021-05-31T07:37:47.69+00:00

    Hi ChandraKumari-3622,
    In addition, here are some considerations about changing domain for SQL Server which might help.
    Best Regards,
    Amelia

    Was this answer helpful?


  3. Hafeez Uddin 296 Reputation points
    2021-05-31T03:09:24.073+00:00

    And you need to modify from the mail related tables.

    use msdb
    go
    select * from sysmail_account

    go
    select * from sysoperators

    You can use sysmail_update_account_sp and sp_update_operator to update email address from in sysmail_account and sysoperators tables.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.