PDA

View Full Version : اشکال در اتچ کردن دیتابیس



hamzehsh
دوشنبه 19 اردیبهشت 1390, 14:02 عصر
من دوتا دیتا بیس خیلی مهم دارم به دلیل اینکه sql دیگه باز نمیشد. آن را حذف کردم و دوباره نصب کردم.
الان که میخوام دیتابیس ها رو اتچ کنم این پیام روبهم میده. الان نمیدونم دیگه چه باید بکنم خود سایت مایکروسافت هم چیزی توش نداره


TITLE: Microsoft SQL Server Management Studio
------------------------------
Attach database failed for Server 'MAINWSX'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.Exceptio nTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
SQL Server detected a logical consistency-based I/O error: torn page (expected signature: 0xaaaaaaaa; actual signature: 0x56aaaaaa). It occurred during a read of page (1:227) in database ID 9 at offset 0x000000001c6000 in file 'E:\DataBase\budget.mdf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
During redoing of a logged operation in database 'budget', an error occurred at log record ID (1544:273:3). Typically, the specific failure is previously logged as an error in the Windows Event Log service. Restore the database from a full backup, or repair the database.
Could not open new database 'budget'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 824)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=824&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------

حمیدرضاصادقیان
دوشنبه 19 اردیبهشت 1390, 16:08 عصر
سلام.
شما ابتدا فایل log رو جای دیگه کپی کنید و با استفاده از Sp_attach_Single_file_db دیتابیس رو attach کنید.

hamzehsh
دوشنبه 19 اردیبهشت 1390, 16:34 عصر
من اینکارو کرده ام ولی این پیغام رو نمایش میدهد:

Msg 15010, Level 16, State 1, Procedure sp_detach_db, Line 34
The database 'budget' does not exist. Use sp_helpdb to show available databases.
File activation failure. The physical file name "E:\DataBase\budget_log.ldf" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'budget'. CREATE DATABASE is aborted.

حمیدرضاصادقیان
سه شنبه 20 اردیبهشت 1390, 10:06 صبح
دوست عزیز لینکهای زیر رو ببینید.
لینک 1 (http://barnamenevis.org/showthread.php?281201-%D8%AE%D8%B7%D8%A7-%D8%AF%D8%B1-Megency-Mode-%D8%AF%D8%B1-SQL-2005&highlight=Emergency)
لینک 2 (http://barnamenevis.org/showthread.php?110226-%D8%B1%D9%8A%D9%83%D8%A7%D9%88%D8%B1%D9%8A-%D9%88-%D8%A8%D8%A7%D8%B2%D9%8A%D8%A7%D8%A8%D9%8A-%D9%81%D8%A7%D9%8A%D9%84-mdf&highlight=Emergency)
لینک 3 (http://barnamenevis.org/showthread.php?162449-%D8%AE%D8%B1%D8%A7%D8%A8-%D8%B4%D8%AF%D9%86-%D9%81%D8%A7%DB%8C%D9%84-MDF&highlight=Emergency)
لینک 4 (http://barnamenevis.org/showthread.php?112405-%D8%A7%D8%AA%D8%B5%D8%A7%D9%84-%D8%AF%D9%88%D8%A8%D8%A7%D8%B1%D9%87-%D8%A8%D8%A7%D9%86%D9%83-%D8%A8%D9%87-Sql-Server&highlight=Emergency)
لینک 5 (http://barnamenevis.org/showthread.php?93944-%D9%81%D8%A7%DB%8C%D9%84-ldf-%D8%AD%D8%B0%D9%81-%D8%B4%D8%AF%D9%87%21&highlight=Emergency)

SilverGold
دوشنبه 18 دی 1391, 12:13 عصر
vbsdfgsdgsdfgsdfg
Print this page
Email this page
Post a comment
Subscribe me
Add to favorites
User Opinions
No users have voted.
--------------------------------------------------------------------------------
How would you rate this answer?
Helpful
Not helpful
Help us improve. Why was this unhelpful?

Thank you for rating this answer.
If you have an <span class="highlight">mdf</span> file that was not properly detached from SQL Server (possibly due to a hard drive crash), then you may need to <span class="highlight">repair</span> the <span class="highlight">mdf</span> before you are able to attach the database. The following are instructions on how to <span class="highlight">repair</span> the <span class="highlight">mdf</span> file. Replace the filenames with your filename !!!
Make sure you have a copy of eshadata.MDF (or gendata.mdf)
Create a new database called fake (default file locations)
Stop SQL Service
Delete the fake_Data.MDF and copy eshadata.MDF (or gendata.mdf) to where fake_Data.MDF used to be and rename the file to fake_Data.MDF
Start SQL Service
Database fake will appear as suspect in EM
Open Query Analyser and in master database run the following :
sp_configure ´allow updates´,1
go
reconfigure with override
go
update sysdatabases set
status=-32768 where dbid=DB_ID(´fake´)
go
sp_configure ´allow updates´,0
go
reconfigure with override
go
This will put the database in emergency recovery mode
Stop SQL Service
Delete the fake_Log.LDF file
Restart SQL Service
In QA run the following (with correct path for log)
dbcc rebuild_log(´fake´,´h:\fake_log.ldf´)
go
dbcc checkdb(´fake´) -- to check for errors
go
Now we need to rename the <span class="highlight">files</span>, run the following (make sure there are no connections to it) in Query Analyser (At this stage you can actually access the database so you could use DTS or bcp to move the data to another database .)
use master
go
sp_helpdb ´fake´
go
/* Make a note of the names of the <span class="highlight">files</span> , you will need them in the next bit of the script to replace datafilename and logfilename - it might be that they have the right names */
sp_renamedb ´fake´,´eshadata´
go
alter database eshadata
MODIFY FILE(NAME=´datafilename´, NEWNAME = ´eshadata´)
go
alter database eshadata
MODIFY FILE(NAME=´logfilename´, NEWNAME = ´eshadata_Log´)
go
dbcc checkdb(´eshadata´)
go
sp_dboption ´eshadata´,´dbo use only´,´false´
go
use eshadata
go
sp_updatestats
go
You should now have a working database. However the log file will be small so it will be worth increasing its size. Unfortunately your <span class="highlight">files</span> will be called fake_Data.MDF and fake_Log.LDF but you can get round this by detaching the database properly and then renaming the <span class="highlight">files</span> and reattaching it.
Run the following in QA
sp_detach_db eshadata
--now rename the <span class="highlight">files</span> then reattach
sp_attach_db ´eshadata´,´h:\dvd.mdf´,´h:\DVD.ldf´