A little something about everything

internet marketing and website development made simple..

Last Resort MS SQL 2005/2008 Database Repair

NOTICE!! BACKUP DATABASE FILES BEFORE DOING THIS, DO IT AT YOUR OWN RISK!

I don't want anyone sending me hate mail because this did not work, however it does work (most of the time).

If you are getting these errors:

  • cannot be opened due to inaccessible files or insufficient memory or disk space
  • the log cannot be rebuilt because there were open transactions/users when the database was shutdown
  • unable to open the physical file
  • the system cannot find the file specified
  • error 5120
  • huge ldf file, restore from backup hangs at 100%
  • HDD IO maxed out on ldf file during restore from .bak file
  • how to restore just the mdf

If your getting errors like the above and have tried all other solutions, you can try the following. Be sure to make a backup of your .mdf / .bak file.

In my case I had a database that for some reason created a 600GB ldf file and corrupted itself. While attempting to restore from a backup it would say 100% completed but would continue to run for hours/days. If I stopped the process it would kill the database and not allow me to use it. Here is what needs to be done:

First restore from your .bak file if you have one.

Example code:

RESTORE
DATABASE [dbname] FROMDISK=N'DRIVE:\BACKUPDIR\BACKUPFILE.bak'WITHFILE= 1,NOUNLOAD,REPLACE,STATS=10
GO

in most cases this will fix your database, IF this backup hangs at 100% for too long you can do the following:

now using the resource monitor verify that the mdf file is done writing (VERY IMPORTANT) select disk sort by file, check to see that the disk is only read/write to the .ldf file and not the .mdf file. Once the system has stopped writing to the .mdf file do the following.

  1. stop mssql service
  2. go into the DATA folder and rename the dbname.mdf file to dbname.mdfx
  3. start the mssql service
  4. delete the database (IMPORTANT, UNCHECK option to delete backups)
  5. create new database with the same name and give proper user owner access
  6. stop the mssql service
  7. delete the dbname.mdf & dbname.ldf files
  8. rename the dbname.mdfx to dbname.mdf
  9. start the mssql service and wait a minute for the service to fully start before issuing the following command:

ALTER DATABASE dbname SETEMERGENCY;
GO
ALTER DATABASE dbname SET single_userWITHROLLBACKIMMEDIATE;
DBCC
checkdb('dbname', repair_allow_data_loss);
GO
GO

.pdf files hosted on IIS 7.5 lock up when downloading in firefox

This issue now has a hotfix however, if you don't want to take a performance hit that this hotfix causes then you can simply do the following to solve the problem with pdf files and IIS 7.5

  1. Open "IIS Manager" on your server
  2. Select your service instace
  3. Select "MIME Types" under IIS
  4. Select ".pdf" then click "edit"
  5. Chenge the MIME type from "application/pdf" to "application/octet-stream"

This will cause the web server to treat the file as a download instead of a pdf application. From IE8 pdf files will open as normal, in firefox it will first download the file in full then open it.

How to merge duplicate contacts using microsoft outlook

First thing you should do is verify that your contacts in outlook sync with any other device you have contacts on. You can do this with MailSync+ or other similar solutions.

 

Now open outlook and select your contacts folder, then changing to list view will make this much quicker.

  • Select a duplicate entry and use Ctrl+C (to copy the entry)
  • Select the entry you would like to merge the duplicate into, use Ctrl+V and it will tell you of any differences. At which point you can choose to accept the changes or cancel.
  • Go back to the duplicate and use Del to remove it.

That's it you're done.

you can also use the import merge method for bulk duplicate entries.

Cannot access IP on windows 2008 R2 server from external network

This problem can occur two way, one is cause by the server not updateing your gateway routers arp tables. You can solve this problem by logging into your router and clearing the arp tables. for instace, on a cisco router your would do the following:

using serial or hyperterminal if available

  • connect to your router
  • password: (enter password)
  • router> enable
  • password: (enter password)
  • router# clear arp
  • router# write mem
  • router# exit

done.

The other problem is caused when using Network Load Balancing (NLB) on windows 2008 / 2008 R2 Server

For more information on this issue use these links:

http://support.microsoft.com/kb/960916

http://blogs.technet.com/b/networking/archive/2009/01/15/unable-to-connect-to-windows-server-2008-nlb-virtual-ip-address-from-hosts-in-different-subnets-when-nlb-is-in-multicast-mode.aspx