If you have spent a lot of hours writing a query and after that accidentally restart your PC or close the SQL Management Studio or a lightening strike you and you haven't saved your query - fear not! There is still a little chance that you work is not completely lost.
You can check in the directory that Management Studio keeps its temporary files:
%UserProfile%\Documents\SQL Server Management Studio\Backup Files\
Hopefully, you can find there a bunch of files named similar to "~AutoRecover.~vs6820.sql" and one of them might be your file. It's a long shot but still worth trying if you desperate ;)
Thanks to this thread for saving me: http://www.sqlservercentral.com/Forums/Topic500268-149-1.aspx