RSS

Category Archives: SQL Server

Unlock the ‘sa’ account in SQL Server

Just thought I would add this invaluable bit of SQL as it comes up time and time again here.  You only get a couple of attempts to give the correct password to the sa account when loggin into SQL Server before the account becomes locked.

If this happens hopefully you will have a backup admin account or able to log in via integrated authentication.

If this is the case, log in and open a new Query window and type the following:

ALTER LOGIN sa WITH PASSWORD = ‘new_password’ UNLOCK

Job done, the sa account is now unlocked ready for someone to come along and lock it out again!!

Advertisements
 
 

Resetting Procedure Cache in SQL Server

Just a quick post but more for the fact that I don’t forget this in the future.  You might find that when optimising your sprocs, that they always run a lot quicker second time round due to caching. 

To reset the cache on each run of the SPROC just add these 2 lines to the top.  Remeber to remove these in production environments though

DBCC FREEPROCCACHE

DBCC DROPCLEANBUFFERS

 
Leave a comment

Posted by on February 17, 2011 in SQL Server