SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


CREATE DATABASE FOR ATTACH_REBUILD_LOG


CREATE DATABASE FOR ATTACH_REBUILD_LOG

Author
Message
mtassin
mtassin
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4916 Visits: 72519
Have a new SQL server instance we've spun up.

So I moved a few databases to it. Via detach, attach.

Normally when I attach a database without the log file if I remove the log file from the screen (using SSMS) or use ATTACH_REBUILD_LOG, the log file will be created in the Log directory as specified in server properties.

However, on my newest server it creates the logs in the data directories (wrong disk spindles).

If I create a new database, the logs are created in the right place, so I'm a bit stumped...

Any ideas?



--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
noeld
noeld
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10102 Visits: 2048
For reasons like this I always use TSQL and specify the path. No UI surprises "ever"!


* Noel
mtassin
mtassin
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4916 Visits: 72519
That's great, unless you want to recreate the log.

CREATE DATABASE [name] ON (FILENAME = [path to mdf]) LOG ON (FILENAME = [path to ldf]) FOR ATTACH REBUILD LOG


will give an error if the log file isn't in place. When you're dealing with limited bandwidth, and sever time constraints, leaving the log files behind if you get a clean detach can be the best choice.


CREATE DATABASE [name] ON (FILENAME = [path to mdf]) FOR ATTACH_REBUILD_LOG


should create the log file in the default log store for the server, but it's putting it where the database is.

The last 4000 databases I moved this way put the logs in the right places.



--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91469 Visits: 45285
I have to ask, why are you attaching a database without a log?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


mtassin
mtassin
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4916 Visits: 72519
Because that's what I was told to make happen. When I had to move 4000 databases, it worked great... this time I have less time to move about 200 of them, and rather than keep the existing logs, I'd like start these databases with fresh new ones that I can keep under control because I wrote the backup maintenance plans this time.



--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
GilaMonster
GilaMonster
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91469 Visits: 45285
You do realise that by discarding the logs you are risking the attached database been transactionally inconsistent or even suspect?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


noeld
noeld
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10102 Visits: 2048
In all honesty I hope you are not losing data but it is ***VERY*** bad to do that!


* Noel
mtassin
mtassin
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4916 Visits: 72519
We're not losing data doing this.

If the database is in a transactionally inconsistent state, sql won't attach it and we retrieve the logs as necessary. Out of the last 4000 databases we did this to, this meant we had to copy 3 log files and attach 3 databases manually.

I'm not doing this in emergency mode or forcing the attach, if there's an error on the attach we retrieve the logs, this is an expediency measure, nothing more.

We also take full backups before we do this task. In case we need them. So far we're 4002 out of 4002.



--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search