{"id":281,"date":"2007-07-10T00:00:00","date_gmt":"2007-07-10T00:00:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/temporarily-changing-an-unknown-password-of-the-sa-account\/"},"modified":"2021-09-29T16:22:17","modified_gmt":"2021-09-29T16:22:17","slug":"temporarily-changing-an-unknown-password-of-the-sa-account","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/temporarily-changing-an-unknown-password-of-the-sa-account\/","title":{"rendered":"Temporarily Changing an Unknown Password of the sa Account"},"content":{"rendered":"<p>I have been working with SQL Server since version 6.5. In the early days, SQL Authentication was a given and I understood most of its nuances. Eventually, SQL Server 7.0 and 2000 surfaced along with Active Directory and the promise of Windows Authentication, which was a godsend. Very soon, SQL Authentication began to feel like a relic, a fossil left over for the SQL archeologists clinging to history, decrying backward compatibility as essential to forward momentum. So, I started to install every instance of SQL Server in Mixed Mode Authentication, never really wading from the shallow end to the 6 foot depths of SQL security potential. <\/p>\n<p>I&#8217;m probably like many other DBAs in this respect. And, likewise, the following scenario is likely to visit most DBAs at some point in the travels and travails of their career: an IT manager stands at your cubicle waiting for you to acknowledge his presence. You turn slowly away from a half-baked stored procedure or from setting a background image on your desktop, and see the concern on his face.<\/p>\n<p>&#8220;Do you know the &#8216;sa&#8217; password for Server_57? We are going to need it for an upgrade to our third-party Help Desk management software.&#8221; <\/p>\n<p>The logical flow of the conversation usually goes something like this:<\/p>\n<ol>\n<li>You are the DBA. You should know the sa password  <\/li>\n<li>I use Windows authentication on 97% of the SQL Servers I manage  <\/li>\n<li>I manage 60 SQL Servers  <\/li>\n<li>All SQL Servers are in Mixed mode authentication  <\/li>\n<li>I have installed 20 of the 60 servers  <\/li>\n<li>I know the sa password on all of the 20 servers I installed  <\/li>\n<li>Other DBAs, no longer with the company installed the other 40 servers  <\/li>\n<li>The other DBAs did not fully document the sa password on all instances.  <\/li>\n<li>I know the sa password on 30 of the remaining 40 servers  <\/li>\n<li>Server_57 is not in the 30 remaining servers I know the sa password to  <\/li>\n<li>No one remaining in IT knows the sa password on Server_57  <\/li>\n<li>Server_57 is a production SQL Server  <\/li>\n<li>Server_57 has jobs that may fail if the sa password is changed to a known value to perform the upgrade request  <\/li>\n<li>The upgrade that is requested is high priority and must be accomplished ASAP<\/li>\n<\/ol>\n<p>So, no, you do not know the &#8216;sa&#8217; password, but&#8230;you do know that the &#8216;sa&#8217; password will only be needed for the upgrade, not for ongoing connectivity, so you proffer a solution, &#8220;I will change the &#8216;sa&#8217; password for you for long enough to complete the upgrade, and then I will need to change it back again. This is because I do not know what processes may be trying to use &#8216;sa'&#8221;.<\/p>\n<p>It is permissible, at this point, to wince at the dreadful thought that there might be a process tied to the &#8216;sa&#8217; account. It might seem preferable to change the &#8216;sa&#8217; account password permanently. Thoughtful DBAs would, if they did this, inform job owners of the change ahead of time. Thoughtful job owners should, by right, not be using &#8216;sa&#8217; to begin with.<\/p>\n<h2>The sp_help_revlogin stored procedure <\/h2>\n<p>How does one go about changing a password back to what it was if one does not know what it was initially? It is possible to do this in both SQL Server 2000 and SQL Server 2005. The steps are quite different, but both rely on a very handy stored procedure provided by Microsoft. The stored procedure, <b>sp_help_revlogin<\/b>, was designed to migrate logins from one instance of SQL Server to another, in order to prevent orphaned uses in restored databases. I will not elaborate on the orphaned user issue here, but I will state that it relates to the Security ID or SID created with each user that is specific to an SQL Server instance. What is important is that <b>sp_help_revlogin<\/b> can be used to generate a current hashed password for each SQL Server authenticated login, which can then be used for reverting to the original password should something goes awry after changing to a known password.<\/p>\n<p>The code to create <b>sp_help_revlogin<\/b> as well as <b>sp_hexadecimal<\/b>. on which <b>sp_help_revlogin<\/b> relies, can be found at: <a href=\"http:\/\/support.microsoft.com\/kb\/246133\">http:\/\/support.microsoft.com\/kb\/246133<\/a>.<\/p>\n<h2>Using sp_help_revlogin on SQL Server 2000 <\/h2>\n<p>Executing <b>sp_help_revlogin<\/b> on a source SQL Server produces a script that, when run on a target SQL Server, creates identical logins, including SIDs and passwords. Sample output of <b>sp_help_revlogin<\/b> can be seen in Listing 1.<\/p>\n<p><strong>Listing 1:<\/strong><\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>\/*&#160;sp_help_revlogin&#160;script&#160; <\/code><br \/><code>**&#160;Generated&#160;Jun&#160;28&#160;2007&#160;10:07PM&#160;on&#160;UAFCQASRV103&#160;*\/ <\/code><br \/><code>DECLARE&#160;<\/code><code>@pwd&#160;<\/code><code>sysname <\/code><br \/><code>&#160;&#160;<\/code><code>--&#160;Login:&#160;BUILTIN\\Administrators <\/code><br \/><code>EXEC&#160;<\/code><code>master..<\/code><code>sp_grantlogin&#160;<\/code><code>'BUILTIN\\Administrators' <\/code><br \/><code>&#160;&#160;<\/code><code>--&#160;Login:&#160;sa_test <\/code><br \/><code>&#160;&#160;<\/code><code>SET&#160;<\/code><code>@pwd&#160;<\/code><code>=&#160;<\/code><code>CONVERT&#160;<\/code><code>(<\/code><code>varbinary<\/code><code>(<\/code><code>256<\/code><code>),&#160;<\/code><code>0x01005B20054332752E1BC2E7C5DF0F9<br \/>EBFE486E9BEE063E8D3B332752E1BC2E7C5DF0F9EBFE486E9BEE063E8D3B3<\/code><code>) <\/code><br \/><code>EXEC&#160;<\/code><code>master..<\/code><code>sp_addlogin&#160;<\/code><code>'sa_test'<\/code><code>,&#160;<\/code><code>@pwd<\/code><code>,&#160;<\/code><code>@sid&#160;<\/code><code>=&#160;<\/code><code>0x9BDCD87E84673D46B7FE<br \/>3584D06E970D<\/code><code>,&#160;<\/code><code>@encryptopt&#160;<\/code><code>=&#160;<\/code><code>'skip_encryption'<\/code><\/p>\n<p>Notice the differences between a SQL login account <b>sa_test<\/b> and a Windows group or user, <b>BUILTIN\\Administrators<\/b>. The <b>sa_test<\/b> account, which I am using here as a precursor to changing the actual &#8216;sa&#8217; account, has a password. This hashed password in the script is converted to <b>varbinary<\/b> and then used by <b>sp_addlogin<\/b> to create the login. <\/p>\n<p>In the <b>sp_addlogin<\/b> procedure, there is an option to bypass encryption called &#8216;skip encryption&#8217;. You can review the code of <b>sp_addlogin<\/b>, or other system stored procedures, by executing &#8220;<b>sp_helptext sp_addlogin<\/b>&#8221; in Query Analyzer. When the &#8220;skip encryption&#8221; option is added to the <b>sp_addlogin<\/b> stored procedure an important function is bypassed, which is <b>pwdencrypt()<\/b>.<\/p>\n<p>We will forego uncovering the technical mysteries of <b>pwdencrypt()<\/b>. It is enough to point out that this function is called as an option in <b>sp_addlogin<\/b>.<\/p>\n<p>However, changing the password for an existing login involves use of another system stored procedure, <b>sp_password<\/b>. With <b>sp_password<\/b>, it is not possible by default to bypass the very same function. This makes it problematic to use <b>sp_password<\/b> to change a password using a hashed value, because the hashed value will be doubly encrypted and not retain its original value. In the case of our <b>sa_test<\/b> account, the value of 12345, or 0x01005B20054332752E1BC2E7C5DF0F9EBFE486E9BEE063E8D3B332752E1BC2E7C5DF0F9EBFE486<br \/>E9BEE063E8D3B3, would itself be obfuscated by <b>pwdencrypt()<\/b>. So, we have to bypass this using the same approach as <b>sp_addlogin<\/b> but with slight modification.<\/p>\n<h3>Changing the Password <\/h3>\n<ol>\n<li>Create a login called <b>sa_test<\/b> in SQL Server 2000 using Enterprise Manager or <b>sp_addlogin<\/b>  <\/li>\n<li>Set the password to &#8220;12345&#8221;  <\/li>\n<li>Create the <b>sp_help_revlogin<\/b> from <a href=\"http:\/\/support.microsoft.com\/kb\/246133\">http:\/\/support.microsoft.com\/kb\/246133<\/a>  <\/li>\n<li>Execute <b>sp_help_revlogin<\/b> in Query Analyzer and save the output so we have the hashed password value for &#8220;12345&#8221;  <\/li>\n<li>Change the password of <b>sa_test<\/b> to &#8220;54321&#8221; via Enterprise Manager or using:<br \/>sp_password: sp_password @new=&#8217;54321&#8242;,@loginame=&#8217;sa_test&#8217;<\/li>\n<\/ol>\n<p>Now, forget you ever knew the password was &#8220;12345&#8221;. All you know is that the original password was:<\/p>\n<p>&#8220;0x01005B20054332752E1BC2E7C5DF0F9EBFE486E9BEE063E8D3B332752E1BC2E7C5DF0F9EBFE<br \/>&#160;486E9BEE063E8D3B3&#8243;. <\/p>\n<h3>Changing the password back <\/h3>\n<p>Next is the fun. There are a couple of ways to set the password back to the forgotten\/unknown password. The first is to update the <b>sysxlogins<\/b> table directly, which, of course, is ill-advised. If it is possible to do so, and there is even a special configuration to allow such practices, it can be used as a last resort.<\/p>\n<p>The second technique I will demonstrate involves use of the <b>sp_password<\/b> stored procedure, but with a slight modification.<\/p>\n<h4>Allowing direct updates on sysxlogins <\/h4>\n<p>The option I am referring to is <b>Allow Updates<\/b>. You can see this option by executing <b>sp_configure<\/b>, see Figure 1.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/409-Figure1.gif\" alt=\"409-Figure1.gif\" \/><\/p>\n<p>If this option is off, indicated by a run value of 0, you can not directly update system tables via an ad-hoc query, like the following:<\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>UPDATE&#160;<\/code><code>master..sysxlogins&#160;<\/code><code>SET <\/code><br \/><code>&#160;&#160;&#160;&#160;&#160;&#160;<\/code><code>password&#160;<\/code><code>=&#160;<\/code><code>0x01005B20054332752E1BC2E7C5DF0F9EBFE486E9BEE063E8D3B332752<br \/>E1BC2E7C5DF0F9EBFE486E9BEE063E8D3B3 <\/code><br \/><code>&#160;&#160;<\/code><code>WHERE&#160;<\/code><code>name&#160;<\/code><code>=&#160;<\/code><code>'sa_test'<\/code><\/p>\n<p class=\"MsoNormal\">\n<p>If you execute an update statement that updates the <b>sysxlogins<\/b> table directly, using a hashed password, you will get the following error:<\/p>\n<pre class=\"MsoNormal\"><\/pre>\n<p class=\"MsoNormal\">Server: Msg 259, Level 16, State 2, Line 1<\/p>\n<p class=\"MsoNormal\">Ad hoc updates to system catalogs are not enabled. The system <br \/>administrator must reconfigure SQL Server to allow this.<\/p>\n<p>However, having set the <b>Allow Updates<\/b> option to 1, or True, the same query will work successfully, as shown in Figure 2.<\/p>\n<p><i><img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/409-Figure2.gif\" alt=\"409-Figure2.gif\" \/><\/i><\/p>\n<p>Now that we can update system tables directly, it is possible to issue the same update statement to set the password back to &#8220;12345&#8221; at the appropriate time, see Figure 3.<\/p>\n<p><i><img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/imported\/409-Figure3.gif\" alt=\"409-Figure3.gif\" \/><\/i><\/p>\n<p>To test the connectivity with the former password, &#8220;12345&#8221;, use Enterprise Manager or SQL Server Management Studio to connect to the instance as <b>sa_test<\/b>.<\/p>\n<p>Because this type of request is very rare, there is nothing more to do than set the <b>Allow Updates<\/b> back to 0 for security.<\/p>\n<h4>Using a modified sp_password procedure <\/h4>\n<p>Being inclined to go off-road for the hell of it, I wanted to show how this same task can be accomplished with a slight alteration to the <b>sp_password<\/b> stored procedure. As discussed earlier, it is not possible, unlike for <b>sp_addlogin<\/b>, to bypass the <b>pwdencrypt()<\/b> function. However, you can take the base <b>sp_passsword<\/b> stored procedure and alter the section that encrypts the passed in password. In all fairness, <b>sp_password<\/b> was designed to use legitimate alpha-numeric and character values similar to:<\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>sp_password&#160;<\/code><code>@old<\/code><code>=<\/code><code>'12345'<\/code><code>,&#160;<\/code><code>@new<\/code><code>=<\/code><code>'54321'<\/code><code>,<\/code><code>@loginame<\/code><code>=<\/code><code>'sa_test'<\/code><\/p>\n<p>Fortunately for our purposes, the variable <b>@old<\/b> for sp_password is not required. The section of code in <b>sp_password<\/b> that controls the updating of the new password is in Listing 2. This section is not optional. The <b>pwdencrypt()<\/b> will always be called:<\/p>\n<p><b>Listing 2<\/b>:<\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>&#160;&#160;&#160;&#160;<\/code><code>--&#160;CHANGE&#160;THE&#160;PASSWORD&#160;-- <\/code><br \/><code>UPDATE&#160;<\/code><code>master.dbo.sysxlogins <\/code><br \/><code>&#160;&#160;<\/code><code>SET&#160;<\/code><code>password&#160;<\/code><code>=&#160;<\/code><code>CONVERT<\/code><code>(<\/code><code>varbinary<\/code><code>(<\/code><code>256<\/code><code>),<br \/><\/code><code>pwdencrypt<\/code><code>(<\/code><code>@new<\/code><code>)),<br \/><\/code><code>xdate2&#160;<\/code><code>=&#160;<\/code><code>GETDATE<\/code><code>(),<br \/><\/code><code>xstatus&#160;<\/code><code>=&#160;<\/code><code>xstatus&#160;<\/code><code>&amp;&#160;(~2048) <\/code><br \/><code>&#160;&#160;&#160;&#160;&#160;&#160;where&#160;name&#160;=&#160;@loginame&#160;and&#160;srvid&#160;IS&#160;NULL<\/code><\/p>\n<p>The modification to the &#8220;Change the Password&#8221; section of <b>sp_password<\/b>, which will reside in a new stored procedure called <b>sp_password_omg<\/b>, is in Listing 3.<\/p>\n<p><b>Listing 3<\/b>:<\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>&#160;&#160;&#160;&#160;<\/code><code>--&#160;CHANGE&#160;THE&#160;PASSWORD&#160;-- <\/code><br \/><code>UPDATE&#160;<\/code><code>master.dbo.sysxlogins <\/code><br \/><code>&#160;&#160;<\/code><code>SET&#160;<\/code><code>password&#160;<\/code><code>=&#160;<\/code><code>CONVERT<\/code><code>(<\/code><code>varbinary<\/code><code>(<\/code><code>256<\/code><code>),<\/code><code>@new<\/code><code>) <\/code><br \/><code>&#160;&#160;<\/code><code>WHERE&#160;<\/code><code>name&#160;<\/code><code>=&#160;<\/code><code>@loginame&#160; <\/code><br \/><code>&#160;&#160;&#160;&#160;<\/code><code>AND&#160;<\/code><code>srvid&#160;<\/code><code>IS&#160;<\/code><code>NULL<\/code><\/p>\n<p>All that we are doing is removing the requirement for the <b>pwdencrypt()<\/b> function. The conversion to varbinary is fine since that is the defined length of the column in <b>sysxlogins<\/b>. The added benefit of creating the <b>sp_password_omg<\/b> stored procedure is that it circumvents the need to reconfigure the <b>Allow Updates<\/b> option for ad-hoc queries.<\/p>\n<p>The statement to execute <b>sp_password_omg<\/b> is:<\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>sp_password_omg&#160;&#160;<\/code><code>@new<\/code><code>=<\/code><code>0x01005B20054332752E1BC2E7C5DF0F9EBFE486E9BEE063E<br \/>8D3B332752E1BC2E7C5DF0F9EBFE486E9BEE063E8D3B3<\/code><code>,<\/code><code>@loginame<\/code><code>=<\/code><code>'sa_test'<\/code><\/p>\n<p>To this point, I have shown a way to change a SQL user&#8217;s password to a new value with the facility to revert back to an unknown value if required. This has worked well for our test user, <b>sa_test<\/b>, which was really important to do prior to moving onto the all-powerful &#8216;sa&#8217;. The same techniques work the same for &#8216;sa&#8217; with one minor caveat: the <b>sp_help_revlogin<\/b> stored procedure automatically excludes &#8216;sa&#8217; from the list of accounts to create logins for. Listing 3 shows the exclusion code from <b>sp_help_revlogin<\/b>.<\/p>\n<p><b>Listing 3<\/b><\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>IF&#160;<\/code><code>(<\/code><code>@login_name&#160;<\/code><code>IS&#160;<\/code><code>NULL) <\/code><br \/><code>DECLARE&#160;<\/code><code>login_curs&#160;<\/code><code>CURSOR&#160;FOR <\/code><br \/><code>SELECT&#160;<\/code><code>sid<\/code><code>,&#160;<\/code><code>name<\/code><code>,&#160;<\/code><code>xstatus<\/code><code>,&#160;<\/code><code>password&#160; <\/code><br \/><code>&#160;&#160;<\/code><code>FROM&#160;<\/code><code>master..sysxlogins <\/code><br \/><code>&#160;&#160;<\/code><code>WHERE&#160;<\/code><code>srvid&#160;<\/code><code>IS&#160;<\/code><code>NULL&#160; <\/code><br \/><code>&#160;&#160;&#160;&#160;AND&#160;<\/code><code>name&#160;<\/code><code>&lt;&gt;&#160;<\/code><code>'sa'<\/code><\/p>\n<p>In order to allow the above steps to work with &#8216;sa&#8217; as easy as we worked with &#8220;sa_test&#8221;, we simply comment out the exclusion, as shown in Listing 4.<\/p>\n<p><b>Listing 4<\/b><\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>IF&#160;<\/code><code>(<\/code><code>@login_name&#160;<\/code><code>IS&#160;<\/code><code>NULL) <\/code><br \/><code>DECLARE&#160;<\/code><code>login_curs&#160;<\/code><code>CURSOR&#160;FOR <\/code><br \/><code>SELECT&#160;<\/code><code>sid<\/code><code>,&#160;<\/code><code>name<\/code><code>,&#160;<\/code><code>xstatus<\/code><code>,&#160;<\/code><code>password&#160; <\/code><br \/><code>&#160;&#160;<\/code><code>FROM&#160;<\/code><code>master..sysxlogins <\/code><br \/><code>&#160;&#160;<\/code><code>WHERE&#160;<\/code><code>srvid&#160;<\/code><code>IS&#160;<\/code><code>NULL&#160;<\/code><code>\/*&#160;AND&#160;name&#160;&lt;&gt;&#160;'sa'&#160;*\/<\/code><\/p>\n<h2>Using sp_help_revlogin on SQL Server 2005 <\/h2>\n<p>So, now that we know how to temporarily change an unknown password of the SA account in SQL Server 2000, let&#8217;s do the same in SQL Server 2005. Fortunately, the procedure is almost identical, save for the <b>sp_help_revlogin<\/b> stored procedure. Yes, we will still need to add the same comment to omit the &#8216;sa&#8217; account as we did in Listing 4. The slight variation of the driving <b>SELECT<\/b> statement can be seen in Listing 5.<\/p>\n<p><b>Listing 5<\/b><\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>SELECT<br \/>&#160;&#160; <\/code><code>p.sid<\/code><code>,<br \/>&#160;&#160; <\/code><code>p.name<\/code><code>,<br \/>&#160;&#160; <\/code><code>p.type<\/code><code>,<br \/>&#160;&#160; <\/code><code>p.is_disabled<\/code><code>,<br \/>&#160;&#160; <\/code><code>p.default_database_name<\/code><code>,<br \/>&#160;&#160; <\/code><code>l.hasaccess<\/code><code>,<br \/>&#160;&#160; <\/code><code>l.denylogin&#160; <\/code><br \/><code>&#160;&#160;<\/code><code>FROM <\/code><br \/><code>&#160;&#160;&#160;&#160;&#160;&#160;<\/code><code>sys.server_principals&#160;p&#160;<\/code><code>LEFT&#160;<\/code><code>JOIN&#160;<\/code><code>sys.syslogins&#160;l <\/code><br \/><code>&#160;&#160;&#160;&#160;&#160;&#160;<\/code><code>ON&#160;<\/code><code>(&#160;<\/code><code>l.name&#160;<\/code><code>=&#160;<\/code><code>p.name&#160;<\/code><code>)&#160; <\/code><br \/><code>&#160;&#160;<\/code><code>WHERE&#160;<\/code><code>p.type&#160;<\/code><code>IN&#160;<\/code><code>(&#160;<\/code><code>'S'<\/code><code>,&#160;<\/code><code>'G'<\/code><code>,&#160;<\/code><code>'U'&#160;<\/code><code>)&#160;<\/code><code>\/*AND&#160;p.name&#160;&lt;&gt;&#160;'sa'*\/<\/code><code><\/code><\/p>\n<p>The other difference between SQL Server 2000 and 2005 is the result output of <b>sp_help_revlogin<\/b>. In SQL Server 2000 an <b>sp_addlogin<\/b> statement was created. In SQL Server 2005, a <b>CREATE LOGIN<\/b> statement is created: <\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\"><code>Login:&#160;sa <\/code><br \/><code>CREATE&#160;<\/code><code>LOGIN&#160;[sa]<br \/>&#160;&#160; <\/code><code>WITH&#160;<\/code><code>PASSWORD&#160;<\/code><code>=&#160;<\/code><code>0x01004086CEB6301EEC0A99<br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 4E49E30DA235880057410264030797&#160;HASHED<\/code><code>,<br \/>&#160;&#160; <\/code><code>SID&#160;<\/code><code>=&#160;<\/code><code>0x01<\/code><code>,&#160;<br \/>&#160;&#160; <\/code><code>DEFAULT_DATABASE&#160;<\/code><code>=&#160;<\/code><code>[master]<\/code><code>,<\/code><\/p>\n<p class=\"MsoNormal\"><code>&#160;&#160; CHECK_POLICY&#160;<\/code><code>=&#160;OFF<\/code><code>,<\/code><\/p>\n<p class=\"MsoNormal\"><code>&#160;&#160; CHECK_EXPIRATION&#160;<\/code><code>=&#160;OFF<\/code><\/p>\n<p>Notice the use of <b>HASHED<\/b> in the output. We will use this password value, not in <b>sp_password<\/b> or in a direct update statement, but in an <b>ALTER LOGIN<\/b> statement as follows:<\/p>\n<pre><\/pre>\n<p class=\"MsoNormal\">ALTER LOGIN sa WITH PASSWORD = <br \/>0x01004086CEB6301EEC0A994E49E30DA235880057410264030797 HASHED<\/p>\n<p>And that is it. The password is set back to the unknown one, without the need to alter any system stored procedures or change server configurations. At this point you can tell the IT Manager with the deadline, and the dire need for the &#8216;sa&#8217; password, that he can go ahead with his updates.<\/p>\n<p>Any additional directives for him to relay to the vendor the insanity of requiring use of the &#8216;sa&#8217; account, are optional at this point. However, a strong admonition that he should let you know the moment his updates are complete is essential.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You are asked for the sa password for a SQL Server in order to perform a software upgrade. You, the DBA, don&#8217;t know the password and it&#8217;s not documented. Rodney Landrum provides a way out of this dilemma, demonstrating two techniques for temporarily changing the password, and then returning it to its previous unknown value.&hellip;<\/p>\n","protected":false},"author":221800,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143531],"tags":[4800,4802,4801,4804,4150,4151,4803,4252],"coauthors":[],"class_list":["post-281","post","type-post","status-publish","format-standard","hentry","category-t-sql-programming-sql-server","tag-sa-password","tag-sp_addlogin","tag-sp_help_revlogin","tag-sp_password","tag-sql","tag-sql-server","tag-sysxlogins","tag-t-sql-programming"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/221800"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":4,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"predecessor-version":[{"id":92568,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/281\/revisions\/92568"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=281"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}