Showing posts with label or. Show all posts
Showing posts with label or. Show all posts

Friday, February 17, 2017

Monday, September 21, 2015

Database cannot be opened due to inaccessible files or insufficient memory or disk space

Database cannot be opened due to inaccessible files or insufficient memory or disk space


Msg 945, Level 14, State 2, Line 1
Database 'db' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.


Solution:
Check Microsoft SQL Server error log and determine reason for the cause.
If it is because of a persistent I/O error related to Application Programming Interface, a torn page, or other hardware issues, resolved it and restore it with help of backup. But if there is no availability of backups then try DBCC CHECKDB repair option.
 If possible add some disk space to files drive or cleanup some disk space.
Verify the permissions of user account.
Verify if the database is property is set to AutoGrow On.
.mdf and .ldf files should not be marked as Read Only on windows level.


If none of the above solved Issue: Try this


1. Change the database to offline to clear the db status

use master
alter database dbname set offline

2. Now change the database to online, at this step log file and data files will be verified by sql server


use master
alter database dbname set online


Tuesday, August 20, 2013

Enable or Disable Logins with Stored Procedure

create procedure toggle_login (@login_name nvarchar(125), @set_enable bit)
as
begin

declare @sql_command nvarchar(500)
set @sql_command = 'ALTER LOGIN [' + @login_name + '] ' + case when @set_enable = 1 then 'ENABLE' else 'DISABLE' end
print @sql_command
exec sp_executesql @sql_command
end

 
--usage of above stored procedure

exec toggle_login 'domain\loginname,0