Tuesday, June 19, 2012

Detach and Attach database in SQL Server


some of the commands I used today.

alter database xxx set single_user with rollback immediate

exec sp_detach_db [xxx]

exec xp_cmdshell 'del or rename the log file'
exec sp_attach_db [xxx],'path to the mdf file'

alter database [xxx]set recovery simple|full

alter database [xxx] modify file ( name='xxx_log' ,filegrowth= 100mb)
--remove the strong windows passwork policy checking

alter login sa with check_policy = off
sp_password  @old =   'xxx',
     @new = 'yyyy'
     ,@loginame = 'sa'

No comments: