Posts

Showing posts from October, 2018

Great article about CPU utilization

Image
https://blogs.msdn.microsoft.com/docast/2017/07/30/sql-high-cpu-troubleshooting-checklist/ https://blogs.msdn.microsoft.com/docast/2017/07/30/sql-high-cpu-troubleshooting-checklist/ WITH DB_CPU AS (SELECT DatabaseID,  DB_Name(DatabaseID)AS [DatabaseName],  SUM(total_worker_time)AS [CPU_Time(Ms)]  FROM sys.dm_exec_query_stats AS qs  CROSS APPLY(SELECT CONVERT(int, value)AS [DatabaseID]   FROM sys.dm_exec_plan_attributes(qs.plan_handle)   WHERE attribute =N'dbid')AS epa GROUP BY DatabaseID)  SELECT ROW_NUMBER()OVER(ORDER BY [CPU_Time(Ms)] DESC)AS [SNO],  DatabaseName AS [DBName], [CPU_Time(Ms)],  CAST([CPU_Time(Ms)] * 1.0 /SUM([CPU_Time(Ms)]) OVER()* 100.0 AS DECIMAL(5, 2))AS [CPUPercent]  FROM DB_CPU  WHERE DatabaseID > 4 -- system databases  AND DatabaseID <> 32767 -- ResourceDB  ORDER BY SNO OPTION(RECOMPILE); If you get a plan handle pass that plan handle to the below DMV and you will get the execution plan of the query sys.dm_

How to take backup for database in MONGODB

Image
MongoDB is a CASE SENSITIVE. We can run below command through COMMAND PROMPT . But ensure you are running this command prompt with "Run as Administrator" If you see above image , it has taken backup for all the databases in the MongoDB. and placed it in the below folder. You no need to create folders in the respective drive. Just mention Drive name automatically folders will get create under the specific folder like you see in the below . image. And you can see that in BSON and JSON file structure. And it created each sub folder for each databases like shown below.

Which process taking which port number

Image
Run command prompt(cmd) as administrator. type the below command netstat -nab The results which are in red port numbers. if we want to export these results to notepad run the below command. netstat -nab | clip Open notepad and paste it in the note pad

RESTORING DATABASE WITH T-SQL SCRIPT

RESTORE DATABASE [Sample] FROM DISK = 'D:\School\Sample_FULL_10102018.BAK' WITH RECOVERY ,    MOVE 'Sample' –Logical file name of the data file TO 'D:\School\School_Data.mdf' ,    MOVE 'Sample_log'-- Logical file name of the log file TO 'D:\School\School_Log.ldf' ;

Who is the owner which database in SQL SERVER

SELECT name , suser_sname ( owner_sid ) AS Database_Owner FROM sys . databases