Determine Size of a Table in SQL Server

by ebarcza 7/31/2012 9:46:00 AM

sp_spaceused ‘Tablename’

 

 

   1:  CREATE PROCEDURE GetAllTableSizes
   2:  AS
   3:  /*
   4:      Obtains spaced used data for ALL user tables in the database
   5:  */
   6:  DECLARE @TableName VARCHAR(100)    --For storing values in the cursor
   7:   
   8:  --Cursor to get the name of all user tables from the sysobjects listing
   9:  DECLARE tableCursor CURSOR
  10:  FOR 
  11:  select [name]
  12:  from dbo.sysobjects 
  13:  where  OBJECTPROPERTY(id, N'IsUserTable') = 1
  14:  FOR READ ONLY
  15:   
  16:  --A procedure level temp table to store the results
  17:  CREATE TABLE #TempTable
  18:  (
  19:      tableName varchar(100),
  20:      numberofRows varchar(100),
  21:      reservedSize varchar(50),
  22:      dataSize varchar(50),
  23:      indexSize varchar(50),
  24:      unusedSize varchar(50)
  25:  )
  26:   
  27:  --Open the cursor
  28:  OPEN tableCursor
  29:   
  30:  --Get the first table name from the cursor
  31:  FETCH NEXT FROM tableCursor INTO @TableName
  32:   
  33:  --Loop until the cursor was not able to fetch
  34:  WHILE (@@Fetch_Status >= 0)
  35:  BEGIN
  36:      --Dump the results of the sp_spaceused query to the temp table
  37:      INSERT  #TempTable
  38:          EXEC sp_spaceused @TableName
  39:   
  40:      --Get the next table name
  41:      FETCH NEXT FROM tableCursor INTO @TableName
  42:  END
  43:   
  44:  --Get rid of the cursor
  45:  CLOSE tableCursor
  46:  DEALLOCATE tableCursor
  47:   
  48:  --Select all records so we can use the reults
  49:  SELECT * 
  50:  FROM #TempTable
  51:   
  52:  --Final cleanup!
  53:  DROP TABLE #TempTable
  54:   
  55:  GO 

Tags:

SQL SERVER

SQl 2008 Shrinking the transaction Log

by ebarcza 7/31/2012 9:38:00 AM

When issuesing these TSQL commands, make sure you're an admin and the target database is selected/active

 

  1. Open a query window
  2. make sure your target database is active by issueing a 'use databasename' statement, or selecting the appropriate database in the dropdown
  3. Change the Recovery Model to Simple; Alter database databaseName SET Recovery Simple
  4. Shrink the file using DBCC ShrinkFile; DBCC Shrinkfile('Logical name of Log', 1)
  5. Then switch it back to FULL database recovery mode if desired


Tags:

SQL SERVER

Server.CreateObject Failed VB6 DLL

by ebarcza 7/31/2012 6:54:00 AM

This usually means that you have not registered the DLL, or the dll is missing from the system.

Make sure the dll is in the proper location and then register the dll with regsvr32 like this in a command window, make sure you run as administrator!

Also, if you are running this as a classic app on IIS7, make sure you enable the app pool to run in 32 bit mode... Click here to see how

regsvr32 D:\Domains\uesdev\components\UESGasManagement.dll

Tags:

ASP Classic

Server.GetLastError is null

by ebarcza 7/26/2012 10:27:00 AM

If you want to access Server.GetLastError from an other place other than Global.assax then you need to make the following tweak in your web.config file:redirectMode"ResponseRewrite"


<customErrors
mode="RemoteOnly" defaultRedirect="~/errors/GeneralError.aspx" redirectMode="ResponseRewrite" />

Then you can access the error object from the defaultRedirect page directly like this:

   1:  Exception ex = Server.GetLastError();
   2:    if (ex != null)
   3:      {
   4:          if (ex.GetBaseException() != null)
   5:              ex = ex.GetBaseException();
   6:      }




Tags:

ASP.NET Enterprise Library

The INSTANCESHAREDDIR command line value was not specified

by ebarcza 7/23/2012 6:38:00 AM

This works:

setup.exe /Action=Install /INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server" /INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server" /INSTANCEDIR="C:\Program Files\Microsoft SQL Server"

Tags:

SQL SERVER

SRW224P factory reset and password rest

by ebarcza 7/9/2012 6:58:00 AM

1. Connect to the console port using terminal emulation parameters (typically 38400, 8, 0, 1, None)
2. Reboot switch (Remove power)
3. Hold down Ctrl U while rebooting
a. Menu will be displayed
4. Select>  [D] Delete file
5. Type startup-config (be sure that this is the ONLY file that you delete – if you delete other files, you will have to reload the firmware)
6.
BOOM - switch reset -  you have erased the configuration file and you should be able to reboot and login with the default username and password.

 


Tags:

Visual Studio setup cannot run in compatibility mode.

by ebarcza 7/5/2012 8:48:00 AM

To change the compatibility mode take the following steps:

  1. Right click on setup.exe and click Properties
  2. Switch to the Compatibility tab
  3. Untick the "Run this program in compatibility mode for" checkbox
  4. If you have a button at the bottom of the dialog entitled "Show settings for all users" click this and repeat step 3 in this window.
  5. Click OK until you have dismissed all dialog windows
  6. Go back to the uninstall entry and uninstall as normal.

Tags:

Visual Studio 2010

How to disable postback on an asp Button

by ebarcza 7/3/2012 7:42:00 AM

Have your javascript return false when it's done.

<asp:button runat="server".... OnClientClick="myfunction(); return false;" /> 

Tags:

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  November 2017  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Recent comments

Tags

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

Sign in