Category Archives: SQL Server

TRUNCATE / SHRINK Log File – SQL Server 2008

PLEASE READ THIS BEFORE TAKING ANY ACTION. One of my database’s log file grew to 251 GB. I was not able to take its backup or detach database for the purpose of moving this database to another server. It was … Continue reading

Posted in Knowledge Sharing, SQL Server, Troubleshooting | Leave a comment

SQL Server 2005 – Shrink log file of all databases

One of database server was running out of disk space. The culprit was the very large SQL server log files. Using following script i was able to shrink log files of all databses in a SQL server instance so creating … Continue reading

Posted in Knowledge Sharing, SQL Server, Troubleshooting | Leave a comment

Searching a string in SQL server 2005 -

It is very tedious to find out all Database objects (functions, stored procedures) containing a particular¬†string. Here is the script to get it- DECLARE @Search varchar(255) SET @Search=’texttofind’ SELECT DISTINCT o.name AS Object_Name,o.type_desc FROM sys.sql_modules m INNER JOIN sys.objects o … Continue reading

Posted in Knowledge Sharing, SQL Server, Troubleshooting | 4 Comments

Searching a string in all tables in a Database

The following¬† Stored Procedure can help us to search for a string within all columns and rows of all tables in a Database. CREATE PROC SearchAllTables ( @SearchStr nvarchar(100) ) AS BEGIN CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630)) SET … Continue reading

Posted in Knowledge Sharing, SQL Server, Troubleshooting | 4 Comments