powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Help!!!
4 сообщений из 4, страница 1 из 1
Help!!!
    #32065611
lelik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Помогите люди добрые

была у нас база MS SQL 7.0 c двумя лог файлами на разных дисках.
Сделали sp_deattach_db
удалили лог файлы
при выполнении sp_attach_single_file_db пишет что имя файла одного лога некорректное и не хочет подключать базу

что делать?!!!
...
Рейтинг: 0 / 0
Help!!!
    #32065612
папа Карло
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
привет. вот, смотри, только я этого ни разу не делал и за последствия ответственности не несу. сделай резервные копии файлов обязательно.

Удачи!

============================================

From: "Jasper Smith" <jasper_smith9@hotmail.com>;
Subject: Re: attaching an MDF without an LDF
Date: Tuesday, August 20, 2002 12:22 AM

Here's a technique I have used in the past - you need to change
the file/database names as this was for a specific case :

If you did not detach the database prior to copying it then you
will not be able to attach it easily (probably).

First thing to try is make sure the folder
'D:\DATA2K\MSSQL$SKINNER2K\DATA\ exists,if not
then create it,copy your MDF there and retry your statement

If that doesn't work then you're in a bit of trouble but you can try this

1) Make sure you have a copy of PowerDVD301_2_Data.MDF

2) Create a new database called fake (default file locations)

3) Stop SQL Service

4) Delete the fake_Data.MDF and copy PowerDVD301_2_Data.MDF
to where fake_Data.MDF used to be and rename the file to fake_Data.MDF

5) Start SQL Service

6) Database fake will appear as suspect in EM

7) 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

8) Stop SQL Service

9) Delete the fake_Log.LDF file

10) Restart SQL Service

11) 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

12) Now we need to rename the files, 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 files , 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','PowerDVD301'
go

alter database PowerDVD301
MODIFY FILE(NAME='datafilename', NEWNAME = 'PowerDVD301_Data')
go

alter database PowerDVD301
MODIFY FILE(NAME='logfilename', NEWNAME = 'PowerDVD301_Log')
go

dbcc checkdb('PowerDVD301')
go

sp_dboption 'PowerDVD301','dbo use only','false'
go

use PowerDVD301
go

sp_updatestats
go

13) You should now have a working database. However the log file
will be small so it will be worth increasing its size
Unfortunately your files 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 files and reattaching
it

14) Run the following in QA

sp_detach_db PowerDVD301


--now rename the files then reattach

sp_attach_db 'PowerDVD301','h:\dvd.mdf','h:\DVD.ldf'

HTH
Jasper Smith
...
Рейтинг: 0 / 0
Help!!!
    #32065626
lelik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Спасибо! Помогло!
мир не без добрых людей.
...
Рейтинг: 0 / 0
Help!!!
    #32065637
lelik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
чем объяснить природу этого явления?
когда у базы был один лог, то все работало
почему же при выполнении sp_attach_single_file_db
сервак не может создать два лог файла?
...
Рейтинг: 0 / 0
4 сообщений из 4, страница 1 из 1
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Help!!!
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]