Sunday, July 29, 2018

MySQl user grant

======================================

GRANT ALL PRIVILEGES ON `*`.* TO 'root_login'@'%' IDENTIFIED BY 'Pass@123' WITH GRANT OPTION

GRANT ALL PRIVILEGES ON `%`.* TO 'root_user'@'%' IDENTIFIED BY 'Pass@123' WITH GRANT OPTION

=======================================

Performance check for MySQL

show status where `variable_name` = 'Threads_connected';

show processlist
==================================

-- SET GLOBAL interactive_timeout = 1000; -- 28800 -- carefull

-- SET GLOBAL wait_timeout = 1000; -- 28800 -- carefull

SHOW STATUS WHERE `variable_name` = 'Threads_connected';

SHOW VARIABLES LIKE "max_connections"

====================================

SHOW SESSION STATUS;

show full processlist

show status where `variable_name` = 'Threads_connected';

-- kill 32042; -- carefull
-- pt-kill  -- carefull
SHOW GLOBAL STATUS;

SHOW VARIABLES LIKE "%wait%"

select concat('KILL ',id,';') from information_schema.processlist where Command='Sleep';

-- set global max_connections = 567; -- carefull

Below is to enable the Logs and set it off back
====================================

-- SET GLOBAL general_log = 'ON';

-- SHOW VARIABLES LIKE "general_log%";

-- SET GLOBAL general_log = 'OFF';

Over Clause

Without using Group by you can take the count by 
===================================
SELECT  object_id, index_id, COUNT(*) OVER ()
FROM [msdb].sys.indexes;



Count base on the Object ID
===================================
SELECT object_id, index_id, COUNT(*) OVER (PARTITION BY object_id) FROM [msdb].sys.indexes;

Good example

DECLARE @Test TABLE ( Account INTEGER, TranDate DATE, TranAmount NUMERIC(5,2)); 

 INSERT INTO @Test (Account, TranDate, TranAmount) VALUES (1, '2015-01-01', 50.00), (1, '2015-01-15', 25.00), (1, '2015-02-01', 50.00), (1, '2015-02-15', 25.00), (2, '2015-01-01', 50.00), (2, '2015-01-15', 25.00), (2, '2015-02-01', 50.00), (2, '2015-02-15', 25.00); 

 SELECT Account, TranDate, TranAmount, COUNT(*) OVER (PARTITION BY Account ORDER BY TranDate ROWS UNBOUNDED PRECEDING) AS RowNbr, COUNT(*) OVER (PARTITION BY TranDate) AS DateCount, COUNT(*) OVER (PARTITION BY Account ORDER BY TranDate ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS Last2Count FROM @Test ORDER BY Account, TranDate;

Referd by: http://www.sqlservercentral.com/articles/over+clause/132079/

If you missed any Templates in .Net


if missing templates in .net
-----------------------------------


Example: One time, i missed the Windows form project template in the .Net. So i made it like this.
(** Run as Administrator ****)
Developer command prompt --> run this under admin
then devenv /installvstemplates

Installing Nuget .Net

Via the "Package Manager Console"

    Open the console. "View" > "Other Windows" > "Package Manager Console"
    Then type the following:

    Install-Package Newtonsoft.Json

    Install-Package EntityFramework -Version 6.2.0

Dot Net Disctionary with Data Types

Dictionary<string, Type> sqlToNetTypes;

sqlToNetTypes.Add("int", typeof(int));
sqlToNetTypes.Add("varchar", typeof(string));
sqlToNetTypes.Add("datetime", typeof(DateTime));
sqlToNetTypes.Add("bit", typeof(bool));
sqlToNetTypes.Add("numeric", typeof(float));//or double or decimal as you like...

Type GetNETType(string sqlType)
{
    if(sqlToNetTypes.ContainsKey(sqlType))
    {
        return sqlToNetTypes[sqlType];
    }else
    {
        return typeof(object); //generic type
    }
}

Add/ Remove Proxy settings for Git Hub

Cannot update your git hub, because of the Proxy settings or, you need to remove the Proxy settings, do as follows
git config --global --unset http.proxy git config --global http.proxy 192.168.7.39:8080 in your command prompt

Postgress - Read a XML file from a postgress table XML column

SELECT xmltable.* FROM xmldata, XMLTABLE('//ROWS/ROW' PASSING data COLUMNS id int PATH ...