Wednesday, July 30, 2008

EXEC sp_attach_single_file_db @dbname = 'pubs',
@physname ='C:\MSSQL\Data\pubs.mdf
--if it does not work copy\rename your mdf file -
-good if you copy the file some where else (just in case) create same named DB with log file in old locationstop sql server servicecopy over new mdf file your old mdf
----Start you sql server servicethe db will be or in suspect or emergency mode:
then:--- if SUSPECT----use your_dbgo----
Let's go see what the ERRORLOG says before-- we decide to just repair it--use mastergoalter database suspect_db set emergency----- if your is already there start from this line gouse your_dbgo---- --check what is problemdbcc checkdb(your_db)go---- try select some data from your table--select * from yourtablego---- Go repair it--use mastergoalter database your_db set single_usergodbcc checkdb(your_db, repair_allow_data_loss)goalter database your_db set multi_usergo alter database your_db set onlinego

No comments: