Archive for category SQL server
Delete SQL Log file
May 11
Sometimes, we just do not need the big log file. For example, I have a 40GB log file. I am sure I do not need this log file and want to get rid of it completely to free up the hard drive space. The logic is:
Detach the database
Rename the log file
Attach the database without the log file
Delete the log file
Let’s say, the database name is testDev. In the SQL Server Management Studio,
Highlight the database-> T Read More
The following SQL query returns the size of each table in the specified database.
USE
sp_MSforeachtable @command1=’EXEC sp_spaceused ”?”’,@whereand=’or OBJECTPROPERTY(o.id, N”IsSystemTable”) = 1′
Bookmark on DeliciousDigg this post Recommend on FacebookShare with StumblersTweet about itSubscribe to the comments on this post Read More
There are different methods to remove duplicates in SQL server 2005 where we do not have primary key defined for any table.
In the example I have table with field names FirstName and LastName. To remove duplicates in any table, replace the field names with the actual names.
If we have more columns, then add those columns as well in the declaration part and in the select and where conditions in the query.
Method 1 Read More
SQL DB shrink
Mar 11
To shrink the DB Transaction Log file,USE DatabaseNameGODBCC SHRINKFILE(<log file name>, 1)
To find out the Log file details:USE DATABASENAMEexec sp_helpfile
Bookmark on DeliciousDigg this post Recommend on FacebookShare with StumblersTweet about itSubscribe to the comments on this post Read More
To find out the SQL server version using SQL query:
<code>
SELECT SERVERPROPERTY(‘productversion’), SERVERPROPERTY (‘productlevel’), SERVERPROPERTY (‘edition’)
</code>
Bookmark on DeliciousDigg this post Recommend on FacebookShare with StumblersTweet about itSubscribe to the comments on this post Read More
