How to fix a damaged database

Scenario:
No SQL Server backups, but a file-level backup is available
When you try to attach or restore, you get an error related to log scan number.
Then you try the attach_rebuild_log option, you get an error complaining the server was not cleanly shut down.

Reason:
The file backup did not make the log in consistent state.

Solution: 
Step 1 - Rename the "damaged" mdf and ldf files (e.g., xxxOld.mdf xxx_LogOld.ldf)
Step 2 - Create a new database, but make the logical and physical names the same as the original damaged files.
Step 3 - Take the new database offline(now the database meta-data are in sys.databases)
Step 4 - Rename the two file names to xxxNew.mdf and xxxNew.ldf, and change the two original damaged ones back to the original names.
Step 5 - Try to set the database online,but the database should be in SUSPECT mode
Step 6 - Set the database to EMERGENCY (ALTER DATABASE ...SET EMERGENCY)
Step 7 - Run the script below to rebuild a new log:
ALTER DATABASE Whatever
REBUILD Log ON (Name=YourChoiceLogName, FileName='c:\NewLogFile.log')


Step 8 - It should be in Restricted User mode.set it to Multi_User mode 

The database should be back online now, but you will loose the data not committed to the databases.

Note: This is a recap from Sean McCown's video Watching Hack-attak a damaged DB

Windows 10 Technical Preview: We ran into an installation error. This might be because your PC doesn't meet system requirements or your language isn't available

Problem:

Windows 10 Tecnnical Preview: We ran into an installation error. This might be because your PC doesn't meet system requirements or your language isn't available.

Reason:

I had Windows 8 Pro, upgraded to Windows 8.1 Pro. But I have not updated Win 8.1 yet to the most current.

Solution:
1. Upgrade Window 8.1 first, then run the installation of Windows10TechnicalPreview
2. Download the ISO file, then run it.

No snap-ins have been registered for Windows PowerShell

Problem:
Scenario: Win 7 Prof 64-bit PowerShell 4.0, SQL Server 2014

Step 1: psdrive - no sqlserver drive
Step 2: I added the following two cmdlets in profile.ps1 in the ...\Documents\WindowsPowerShell folder:
      Add-PSSnapin SqlServerCmdletSnapin100
      Add-PSSnapin SqlServerProviderSnapin100

Then I got the error:
     No snap-ins have been registered for Windows PowerShell 

Solution:
In the profile.ps1 file, use the following cmdlet:
     import-module sqlps –DisableNameChecking

The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program.

Problem: 
I got this error message in PowerShell ISE 4.0 when I run the script below. But When I run the same command in PowerShell 4.0 and Start PowerShell from SQL Server, it works fine.

PS SQLSERVER:\sql\localhost\default\databases> dir | %{$DBName=$_.Name;invoke-sqlcmd -database $DBName -query "drop schema NoMoreForEachDB";$DBName}

Solution: 
Run PowerShell ISE 4 as Administrator