Friday 5 September 2014

Shrink logfile dynamics AX

Just a small post for my own archive. I ran into a problem of not having enough space left after deleting a company in AX (the logfile became too big) in my own testenvironment (recovery model is set to simple).  

Shrinking did not solve it. I needed a full backup first, but there's the problem again, no diskspace left :). There appears to be a backup faker for both the db and the db log and after running it, you can shrink the database. 

alter database "dbname" set recovery full

GO

backup database "dbname" to disk='nul'

GO

backup log "dbname" to disk='nul'

GO

alter database "dbname" set recovery simple


GO

And finally Shrink and the logfile is back in proportian. 



Edit: a small update, after a restore of another database, in order to be able to log in, use this script:


UPDATE dbo.UserInfo
SET networkdomain='domain',networkalias='networkname', sid='sidid'

WHERE id='admin';