SQL Server - I need to Help for Detach and Atach Method
Asked By prathap chowdary on 16-Feb-12 09:12 AM
One database having more .ndf files apart from .mdf and .ldf files.
Please helpout me attach and detach method.
for single .mdf and .ldf file i am using this query:
sp_attach_db 'dbname','filename for mdf file','filename for ldf file'
the above queries i am using.
if we are having 34 .ndf files how to attach all those things
Please help me its very urgent.......
Amit Choudhary replied to prathap chowdary on 16-Feb-12 09:51 AM
Since you have more than 16 files,
use CREATE DATABASE database_name FOR ATTACH or CREATE DATABASE database_name FOR_ATTACH_REBUILD_LOG syntex
Even MS will not support sp_detach_db in future version.
Hope it will help you
D Company replied to prathap chowdary on 16-Feb-12 11:05 AM
Simple process to detach from DB is sp_detach_db @dbname= 'YourDBName',@skipchecks = 'true'
Sp_detach_db – this is the stored procedure that does the detach.@dbname – is the name of the database you’re detaching. You don’t really need to use the named parameter like this. I’m doing it only for clarity.
@skipchecks – this parameter defines whether you want SQL to update statistics or not.
you can provide the values are ‘true’ or ‘false’.
Generally we use ‘false’ because there’s no need to update statistics just because you detached a database. This is important because the update statistics portion can take quite a long time, so it’s best to leave that for another time.
Hope its help!!