T-SQL: RIGHT, LEFT, SUBSTRING and CHARINDEX Functions

This article explains the base functionality and uses of the LEFT, RIGHT, SUBSTRING and CHARINDEX functions in SQL. Samples script: Sample Results: Variable Data Results ——————– HELLO WORLD RIGHT Results ————- RLD LEFT Results ———— HEL CHARINDEX Results —————– 6 SUBSTRING Results —————– LO WO Combined Results ——————– HELLO  

Read More

15 Excel Tips on Improving Productivity Using Excel

To format a number as SSN, use the custom format code “000-00-0000?… To format a phone number, use the custom format code “000-000-0000?… To show values after decimal point only when number is less than one, use _($#,##0.00_);_($#,##0_) as formatting code… To remove grid lines from excel worksheet, go to menu > tools > options > and un-check grid lines option. (Excel 2007: office button > excel option > advanced)… To hide a worksheet, go to menu > format…

Read More

20 Tips in How to Solve Common problems using Excel Formulas

To get the first name of a person, use =left(name,find(” “,name)-1) To calculate mortgage payments, use =PMT(interest-rate,number-of-payments,how-much-loan) To get nth largest number in a range, use =large(range,n)… To get nth smallest number in a range, use = small(range,n)… To generate a random phone number, use =randbetween(1000000000,9999999999), needs analysis toolpak if you are using excel 2003 or earlier… To count number of words in a cell, use =len(trim(text))-len(SUBSTITUTE(trim(text),” “,””))… To count positive values in a range, use =countif(range,”>0?)… To calculate…

Read More

25 Very Useful Keyboard Shortcuts for Excel

1. To format any selected object, press ctrl+1 2. To insert current date, press ctrl+; 3. To insert current time, press ctrl+shift+; 4. To repeat last action, press F4 5. To edit a cell comment, press shift + F2 6. To autosum selected cells, press alt + = 7. To see the suggest drop-down in a cell, press alt + down arrow 8. To enter multiple lines in a cell, press alt+enter 9. To insert a new sheet, press…

Read More

Foreach C#

A program iterates over a collection. The index of each element is not needed. Only the elements are needed. With foreach we access just the elements. A foreach-loop, this is the easiest, least error-prone loop. It is preferred in many program contexts. Here are some samples: using System; class Program { static void Main() { string[] pets = { “dog”, “cat”, “bird” }; // … Loop with the foreach keyword. foreach (string value in pets) { Console.WriteLine(value); } }…

Read More

Find the Server Name or Instance Name using T-SQL

The following instructions are supposed to return the same results,  but sometimes the results can be different. The reason is that SERVERPROPERTY automatically reports changes in the network name of the computer, while @@SERVERNAME don’t. SELECT CONVERT(sysname, SERVERPROPERTY(N’servername’)) GO SELECT @@SERVERNAME When they are run on the default instance they return just the server name, but when run over a named instance they return the server name in the following format: servername/instancename.

Read More

Visual Studio 2015 keyboard shortcuts – The complete list

Analyze Navigate Backward Shift+Alt+3 Navigate Forward Shift+Alt+4 Architecture New Code Map Ctrl+\, Ctrl+O New UMLor Layer Diagram Ctrl+\, Ctrl+N Architecture Context Menus Add Node Ins Both Dependencies B Incoming Dependencies I Outgoing Dependencies O New Comment Ctrl+Shift+K Ctrl+E, C Remove Del Rename F2 Build Build Solution Ctrl+Shift+B Cancel Ctrl+Break Compile Ctrl+F7 Run Code Analysison Solution Alt+F11 Class Diagram Collapse Num – Expand Num + Class View Context Menus Properties Alt+Enter Misc Commit All Edits Shift+Alt+U Move Left Edgetotheleft Ctrl+Shift+,…

Read More

Enable or Disable Multiple RDP Sessions in Windows 2012

How to Enable/Disable Multiple RDP Sessions in Windows 2012. By default, Windows 2012 servers allow a single Remote Desktop session. If only one session is available and you take over another person’s live session, you may choose to enable multiple RDP sessions. This article describes the process for enabling and disabling multiple sessions. Enable Multiple RDP Sessions  Log into the server using Remote Desktop. Open the start screen (press the Windows key) and type gpedit.msc and open it Go…

Read More

UPDATE From SELECT Statement – Using JOIN in UPDATE Statement – Multiple Tables in Update Statement

In recent times I have seen a developer writing a cursor to update a table. When asked the reason was he had no idea how to use multiple tables with the help of the JOIN clause in the UPDATE statement. However, the easiest and the most clean way is to use JOIN clause in the UPDATE statement and use multiple tables in the UPDATE statement and do the task. Let us see the following example. We have two tables Table 1…

Read More