A user's AD account keeps being locked out. The latest idea from colleagues is that their username and password is hard-coded in some database in the instance (a stored procedure for example).

  1. Is this possible?
  2. How would I search the instance for where this could be?
  • This answer on SO probably gives what you're looking for. – LowlyDBA Oct 9 at 17:10

If it's in the text of a proc/function you could use the easy and free to use third party plugin of redgate: SQL Search, there are also ways to do this with TSQL, see answer on stackexchange searching through procedures

However, very likely your proc will fetch the value from a table that stores it, so the proc doesn't have to be hard coded. If you want to search through a bunch of columns at the same time, this link might be useful to you:
Finding string in different tables


To generate a script that you could search through with all database objects/code: Right click on DB > Tasks > Generate Scripts > Next on Intro screen > On Choose objects screen tick 'Select specific database objects' and tick the objects you want to search > On Set Scripting Options Screen, select 'Save to new query window' > Summary Screen - click Next > click finish.

You can now do a Control + F to search through all of the scripts to find your username/password.

It is also possible to use this method to include the data values in the script, though this could be a huge script depending on the size of your database. To do this, on the 'Set Scripting Options' screen, click advanced > then change 'Types of data to script' to schema and data.


What kind of database are you running?

If it's an Oracle Database than you can do a SQL Query on dba_source/all_source and do:

  FROM dba_source ds
WHERE ds.TEXT LIKE '%Username%'

For Microsoft Database you would do:

    OBJECT_DEFINITION(object_id) LIKE '%Username%'

I had a query that would run through every schema/database on a server looking for this information, because what I was looking for might not be in my database, but I'll have to dig it up if you need more than the above.

The first query I remembered, the second I took from here: https://www.mytecbits.com/microsoft/sql-server/search-find-stored-procedure

Good luck!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.