Friday, 20 October 2017

IFF Function in SQL SERVER 2012

IFF function :

   IFF function takes three parameters a)boolean expression b)parameter1 c)parameter2
  •     if boolean expression true then it returns parameter1 else parameter2
         Example:DECLARE @gender int;
                        SET @gender=2
                        SELECT IIF(@gender=1,'Male','female') Gender

                     output:female

Wednesday, 20 September 2017

NPM USEFUL COMMANDS

# GET VERSION
npm -v (or --version)

# GET HELP
npm help
npm

# CREATE PACKAGE.JSON
npm init
npm init -y (or --yes)

# SET DEFAULTS
npm config set init-author-name "YOUR NAME"
npm set init-license "MIT"

# GET DEFAULTS
npm config get init-author-name
npm get init-license

# REMOVE DEFAULTS
npm config delete init-author-name
npm delete init-license

# INSTALLING LOCAL PACKAGES
npm install lodash --save (or npm install --save lodash)
npm install moment --save
npm install gulp gulp-sass --save-dev

# MOVE TO ANOTHER FOLDER
npm install
npm install --production

# REMOVING MODULES
npm uninstall gulp-sass --save-dev
npm remove gulp --save-dev

#INSTALL CERTAIN VERSIONS
npm install lodash@4.17.3 --save

# UPDATE
npm update lodash --save

# INSTALL GLOBAL MODULE
npm install -g nodemon
npm install -g live-server

# RUN NODEMON
nodemon

# FIND ROOT FOLDER
npm root -g

# REMOVE GLOBAL PACKAGES
npm remove -g nodemon

# LISTING PACKAGES
npm list
npm list --depth 0
npm list --depth 1

# INSTALL NODMON LOCALLY
npm install live-server --save-dev

# NPM SCRIPT
"scripts": {
    "start": "node index.js",
    "dev": "live-server"
  },

Thursday, 24 August 2017

Configure Git-bash Command on visual studio code

Install git-bash from https://git-scm.com


Put the bellow line on user setting file, save  and restart your visual studio code
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"

Configure: Visual studio Code on widows right click

First, create a file with a “.reg” extension.  For example,.vsCodeOpenFolder.reg
then positioned to add these contents to the file:
  • Windows Registry Editor Version 5.00
  • ; Open files
  • [HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
  • @="Edit with VS Code"
  • "Icon"="C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe,0"
  • [HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
  • @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
  • ; This will make it appear when you right click ON a folder
  • ; The "Icon" line can be removed if you don't want the icon to appear
  • [HKEY_CLASSES_ROOT\Directory\shell\vscode]
  • @="Open Folder as VS Code Project"
  • "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0"
  • [HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
  • @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
  • ; This will make it appear when you right click INSIDE a folder
  • ; The "Icon" line can be removed if you don't want the icon to appear
  • [HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
  • @="Open Folder as VS Code Project"
  • "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0"
  • [HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
  • @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%V\""
Next, save the file.

Note: the above .reg file assumes that you installed VS Code in the default location—which will be the case for most people. Adjust accordingly if the Code.exe file is installed in a different folder.
Very nice – we are almost done.  Double click on the vsCodeOpenFolder.reg file that you just created.














Sunday, 16 July 2017

How to Get Row Count Of All The Tables In SQL Server Database

Sometimes we want to get the Row Count quickly for all the tables in our Database for analysis. There are multiple ways to do that. We can use TSQL Cursor to loop through all the tables and use count(*) to get the row count.

I am using Catalog views to get this information by using below query. This is a quick way to find the row count for all the tables in a database. The Cursor with Count(*) can be slow as it has to count rows for each of the tables.

USE DBName
GO
SELECT OBJECT_NAME(id) AS TableName,
       rowcnt          AS [RowCount]
FROM   sysindexes s
       INNER JOIN sys.tables t
               ON s.id = t.OBJECT_ID
WHERE  s.indid IN ( 0, 1, 255 )
       AND is_ms_shipped = 0 order by [RowCount] DESC

Friday, 9 June 2017

TIME FORMAT AM/PM IN JAVASCRIPT

JAVASCRIPT TIME AM/PM FORMAT FROM JAVASCRIPT DATETIME:

  1.  dd/mm/yyyy format

function formatDate(date)
{
    var day = date.getDate();
    if (day < 10)
    {
        day = "0" + day;
    }

    var month = date.getMonth() + 1;
    if (month < 10)
    {
        month = "0" + month;
    }

    var year = date.getFullYear();

    return day + "/" + month + "/" + year;
}

   2.d/m/yyyy


function formatDate(date)
{
    var day = date.getDate();
    var month = date.getMonth() + 1;
    var year = date.getFullYear();

    return day + "/" + month + "/" + year;
}