Tag Archives: SQL Server
Reset the password for sa user in SQL Server
osql -S “SERVER_NAME\INSTANCE_NAME” -E -Q “exec sp_password NULL, ‘NewPassword’,’sa'”
Speeding up database access
This is a very thorough article on ways to speed up a SQL database by Matt Perdeck
Script to restore SQL Server database
A lot of people know how to restore an SQL Server database using the SQL Server Management Studio. Sometime it will not work if the database is in use. You have to close all active connections or even to take database offline and then online again.
It is much easier to restore the database via the attached script. Just unzip the file to a folder called C:\RestoreDB and copy the backup file to the same folder. Then edit RestoreDB.bat file and update it with the appropriate information – server name, user name, password, backup name, etc.
The last step is to run RestoreDB.bat – you can double-click it in Windows explorer or can oped a DOS prompt change the folder to C:\RestoreDB and run the script by typing its name and pressing “Enter” key.
TRUNCATE Log File in SQL Server 2008
ALTER DATABASE [TestDb] SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE(TestDbLog, 1)
ALTER DATABASE [TestDb] SET RECOVERY FULL WITH NO_WAIT