Sunday, November 19, 2017

วิธีดู user ที่ online อยู่ใน SQL

exec sp_who

คำสั่งหยุดการทำงานของ thread นั้น
kill [XXX]

Thursday, November 16, 2017

Dynamics Ax 2012 Error Code 90, Unable to connect to database

-- This query will rollback any transaction which is running on that database

-- and bring SQL Server database in a "single user" mode

ALTER DATABASE DATABASENAME SET SINGLE_USER WITH ROLLBACK IMMEDIATE



-- Marking database READ_ONLY, disable logging,

-- and limiting access only to members of the sysadmin fixed server role

ALTER DATABASE DATABASENAME SET EMERGENCY



-- Checks the logical and physical integrity of all the objects in the specified database

DBCC checkdb(DATABASENAME)

-- In case of simple failure then we can use allow data loss option to recover Database



--  DBCC CheckDB (DATABASENAME, REPAIR_ALLOW_DATA_LOSS)



-- Set database accessibility to it's original state, allowing all logins

ALTER DATABASE DATABASENAME SET MULTI_USER

ALTER DATABASE DATABASENAME  SET ONLINE;

EXEC sp_resetstatus DATABASENAME