About Tim

  • Website: or email
  • Biography:

Posts by Tim:

 
0

Determing SQL Server Table Size

on September 3, 2010 in SQL Server

This is a bit of code I found that determines the size used by each table in your database.

Make sure you run DBCC UPDATEUSAGE first to correct any incorrect stats (pages etc) on your tables.

DBCC UPDATEUSAGE (YOUR DATABASE NAME)

DECLARE @TableName VARCHAR(100)    --For storing values in the cursor

--Cursor to get the name of all user tables from the sysobjects listing
DECLARE tableCursor CURSOR
FOR
select [name]
from dbo.sysobjects
where  OBJECTPROPERTY(id, N'IsUserTable') = 1
FOR READ ONLY

CREATE TABLE #TempTable
(
tableName varchar(100),
numberofRows varchar(100),
reservedSize varchar(50),
dataSize varchar(50),
indexSize varchar(50),
unusedSize varchar(50)
)

OPEN tableCursor
FETCH NEXT FROM tableCursor INTO @TableName

WHILE (@@Fetch_Status >= 0)
BEGIN
INSERT  #TempTable
EXEC sp_spaceused @TableName
FETCH NEXT FROM tableCursor INTO @TableName
END

CLOSE tableCursor
DEALLOCATE tableCursor

--Select all records so we can use the reults, ordered by biggest
SELECT *
FROM #TempTable
ORDER BY CAST(LEFT(dataSize,LEN(dataSize)-3) AS NUMERIC(18,0)) DESC

DROP TABLE #TempTable

References:

http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/121/determing-sql-server-table-size.aspx

Tags:

 
0

You receive a “The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect” exception when using NVarchar parameters with Sqlclient

on August 26, 2010 in .NET Framework, SQL Server

The problem I got the following random error: You receive a “The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect” exception when using NVarchar parameters with Sqlclient The Solution Its a known bug with the .Net SqlClient Data Provider.   If you have a field in the database of type nvarchar(max) [...]

 
1

Open XML – OLE Automation Date Issues

on July 26, 2010 in .NET Framework, C#

If you are exporting a date from C# to Excel using 2007, you probably will use the following: Math.Round(DateTime.Now.ToOADate(), 12).ToString() This exports the date as a OLE Automation date recognized by Excel 2007. How ever, in Excel 2010 this was causing issues, every time I exported to Excel 2010, it said that it has to [...]

 
0

New Photo – CheckoutChristchurch.co.nz south by the Church of Good Shepard

on July 23, 2010 in News, Uncategorized

CheckoutChristchurch south on Lake Tekapo by the Church of Good Shepard!

 
1

PRODUCT OF THE WEEK – CAR FIRST AID KIT

on July 22, 2010 in News, Uncategorized

PRODUCT OF THE WEEK: Car First Aid Kit – Perfect kit for the car for any unexpected accidents on the road! Includes plasters, saline, CPR mask plus more..perfect if you are traveling up the snow this winter! http://www.medicsafe.co.nz/car-fa-kit-soft-pack

 
0

Auckland 2011 Website Hickups!

on July 14, 2010 in News

Auckland 2011 Website isn’t too bad but it has a few design flaws! Can you spot them? This appears across all browsers, look closely where the Visitor Services text is.

 
0

EF Strongly Typed ObjectQuery.Include

on July 13, 2010 in .NET Framework, C#

The problem that I faced was having to put up with “hard coded” strings in the ObjectQuery.Include function to load related objects through POCO objects in the Entity Framework. This faced challenges when I renamed columns in the Model which caused a run-time error when recompiling and re-starting the application. Thanks to David Kiff, we [...]

 
0

Fixing the EF Tracing and Caching Provider Wrapper Issue

on July 9, 2010 in .NET Framework, C#

If you have been using the Tracing and Caching Provider Wrappers for the ADO.NET Entity Framework 4.0, you might of come across this error message when creating POCO objects, adding them to a Data Context and commiting them to the database using the Caching Wrapper: [NotImplementedException: The method or operation is not implemented.] EFCachingProvider.EFCachingDataReaderCacheWriter.GetName(Int32 ordinal) [...]

 
0

CheckoutChristchurch – What not to check out??

on July 4, 2010 in News

Here is a picture that was taken from outside Timaru..perhaps this picture has failed? www.checkoutchristchurch.co.nz

 
0

CheckoutChristchurch has a new pic! Clock Tower

on July 1, 2010 in News

Visit http://www.checkoutchristchurch.co.nz to see the Victoria Street Clock Tower in Christchurch! www.checkoutchristchurch.co.nz is powered by jquery, flickr and a twitter feed!

Copyright © 2008-2010 Tim's CodeLab Blog All rights reserved.
Desk Mess Mirrored v1.7 theme from BuyNowShop.com.