Below command will shrink SQL log files and also release unused physical space on drives.
Use DatabaseName
Backup log databasename with no_log
DBCC SHRINKFILE (logfilename)
Blogs about my Technical experience and Activities (I am also maintaining my blog on wordpress http://khurramullah.wordpress.com)
Below command will shrink SQL log files and also release unused physical space on drives.
Use DatabaseName
Backup log databasename with no_log
DBCC SHRINKFILE (logfilename)
Recently we have migrated our SharePoint 2003 from one AD forest to another forest, apart of this change we have also upgraded our backend DB from SQL 2000 to SQL 2005. Recently i faced a very critical issue, one of the heavily used site is not showing search result and the search is timing out. In order to investigate this issue i have identified the query in the SQL profiler and ran it directly on the SQL management studio. It took around 10 minutes to show results in new DB Server (SQL 2005) but the same query is returning result in 1 sec in the old DB server (SQL 2000) i ran the query again with the Query execution plan against both servers and compared it, i have seen the cost for referencing Clustered index is very high in new DB server as compared to old DB server. After some researching i have planned to update DB statistics by using following command;
update statistics tablename
SharePoint create its own indexes which we cannot alter and it uses the hard coded name for indexes such as ix_databasename. As per my analysis after moving DBs from SQL 2000 to SQL 2005 the databases statistics were not updated and indexes were not using optimal path for searching for data that why it is showing results after long delays.
When you have SQL server running in clustering and you changed any startup parameters, it is possible that SQL services will not run due to any incorrect parameter settings. As per Microsoft this is because the cluster service obtains an incorrect protocol setting from a cluster checkpoint when you start the SQL Server service.
In order to fix this issue you have to first remove the last check point by running this command (after making SQL server resource offline)
cluster res "SQL Server (Instancename)" /removecheck: "Software\Microsoft\Microsoft SQL Server\MSSQL.x\MSSQLSERVER
and then fix the startup parameters for all nodes and then run following commands
cluster res "SQL Server (Instancename)" /addcheck: "Software\Microsoft\Microsoft SQL Server\MSSQL.x\MSSQLSERVER"
Following is the Microsoft KB for more details.
If you ever run in a situation like you have only MBs of space left on production SQL servers and your transaction logs are growing bigger and bigger and you want to claim disk space immediately then you might need to run following command
Backup log <Database name> with no_log
This command is not recommended to run in normal circumstances and after this you are not able to recover your database point in time. if you have proper backups configured then you don't need to run this command because after each full backup the transaction logs are automatically truncated. Also in case you have log shipping configured then this command will break your log shipping sequences. Only use if you don't have any space left on physical disk and you don't have any other alternatives available.
if you don't required point in time recovery then change your database recovery model to ‘Simple’ doing this will ensure that your transaction log will not get bigger.
The above command will not reclaim disk space, you have to run DBCC shrink statement or go to the SQL management studio and manually shrink log file.
In SQL server 2005 if you want to check all SQL server sessions following is the command for viewing this;
1 . select * from sys.dm_exec_sessions
But the above command will show the user sessions and as well as the system sessions, if you want to only see the user connections then following is the command;
2. select * from sys.dm_exec_connections
you can also get the session id from the below command and match it with the session_id column of the 2 or 1 command for viewing the specific session information.
3. Select @@SPID