Wednesday 9 October 2013

How to restart the server from network/local
Go to command prompt and use the below command
shutdown /r /t 10 /f /m SERVERNAME

How to shrink T-log file
Sometime, it looks impossible to shrink the Truncated Log file. Following code always shrinks the Truncated Log File to minimum size possible.
USE DatabaseName
GO
DBCC SHRINKFILE(<TransactionLogLogicalName>, 16)
Note: If you are not able to shrink the log file please use below if your database doesn’t require point in time recovery. This breaks the chain of the logs and in future you will not be able to restore point in time. You are recommended to take full back up right before using this query.
BACKUP LOG MyTestDB TO DISK = N’C:\MyTestDB_Adhoc_T_Log.trn’;
BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(<TransactionLogLogicalName>, 16)
GO
How to create Database using Query Analyser
CREATE DATABASE [MyDB]
ON PRIMARY
(
NAME = N’MyDB_data’,
FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\MyDB.mdf’ ,
SIZE = 2048KB ,
FILEGROWTH = 1024KB
)
LOG ON
(
NAME = N’MyDB_log’,
FILENAME = N’C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\MyDB_log.ldf’ ,
SIZE = 1024KB ,
FILEGROWTH = 10%
)
GO

1 comment:

  1. Well written post. I appreciate your guidance for sharing about server disaster recovery plan. I really need to know about it. Great work!

    ReplyDelete