Monday, April 1, 2019

How to Get DATABASE OUT OF SUSPECT MODE MS SQL SERVER

ALTER DATABASE DBName  SET  EMERGENCY
 
DBCC CHECKDB('DBName')
 
ALTER DATABASE DBName SET SINGLE_USER WITH ROLLBACK IMMEDIATE
 
DBCC CHECKDB('DBName', REPAIR_ALLOW_DATA_LOSS)
 
ALTER DATABASE DBName SET MULTI_USER

Monday, August 27, 2018

Error message “Explorer.exe - No such interface supported” in Windows 7

1. Click Start. In the Search box, type CMD. At the top of the window, right-click the cmd icon and choose Run as Administrator.
2. At the prompt, type in FOR /R C:\ %G IN (*.dll) DO "%systemroot%\system32\regsvr32.exe" /s "%G" and press.

This will take several minutes to complete. There will be several C+ Runtime errors that will appear, as well as the system slowing down. Once complete, restart the system and test.

Wednesday, August 8, 2018

How to migrate a MS SQL Server database to a lower version

Solution 1
Generate a script of schema and data using ssms "generate scipts" option

Solution 2
Generate a script of schema using ssms "generate scipts" option
Use data compare wizard is data is too big

Wednesday, November 15, 2017

Slow Database First Code Generation Visual Studio

Running the following on the DB worked for me:
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION=ON
Then, after the update, setting it back using:
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION=OFF

Wednesday, October 18, 2017

Renaming Primary key and references in all tables sql server

Use sp_fkeys procedure to get all foreign keys

EXEC sp_fkeys 'Students', 'Academics'

Use nimble text to update keys

UPDATE $5.$6
SET $7 = $1.$2.$3
FROM $5.$6
INNER JOIN $1.$2 on $5.$6.$7 =  $1.$2.$3