How to check if the table exists in a database in SQL Server ?

To check if the table exists in a database in SQL Server , you can use the INFORMATION_SCHEMA view.

How to check if the table exists in a database in SQL Server ?

Here’s a query that gets the table details of the table “Department” in the AdventureWorks2014 database.

use AdventureWorks2014
GO
SELECT * 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_NAME = 'Department'


Read more

Using Expressions for SORT Order in SQL Server

You might want to sort the results of an query in a different order from the traditional sort (Ascending/Descending) order.

For example , you wish to sort the Department records by GroupName and force the GroupName “Manufacturing” to be sorted first.

How to use expression to sort records in SQL Server ?

You could do this by using the expression which would provide the sort order that you require.

Here’s a sample query demonstrating how this can be done.

Use AdventureWorks2014
GO
SELECT * from HumanResources.Department
ORDER BY CASE GroupName   
WHEN 'Manufacturing' THEN NULL      
ELSE GroupName      
END;  

Read more

How to find the Windows OS Build version from Command Line in Windows 10 ?

There are multiple options to find the Windows OS Build version from command line in Windows 10.

How to find the Windows OS Build version from Command Line in Windows 10 ?

The first one is using the command line utility command called “ver” . Just open the command prompt from your Windows 10 machine and enter ver and press enter key which should display the Windows 10 build number.

C:\Users\senthil>ver

Microsoft Windows [Version 10.0.14366]

C:\Users\senthil>


Read more

How to disable Block on single Line in Visual Studio 2015.

When you create an auto property in Visual Studio 2015 , you will notice that it would be in a single line as shown below.

public int Name { get; set; }

When you use the shortcut for formatting in Visual Studio 2015 (Ctrl + K and Ctrl +D) , you will notice that the formatting would stay like the one shown in the above code.

There are times when you might want to have this formatting in multi-line instead of a single line. (I would prefer single line though :)).

How to Disable Block on single Line in Visual Studio 2015 ?

To change this behaviour , follow the below steps.

1. Launch Visual Studio 2015 and navigate to Tools -> Options.

2. In the Options Dialog left sidebar , select Text editor -> C# -> Formatting -> Wrapping and then uncheck the option “Leave block on single line”.

3. Click ok button and now apply the formatting. You should see the auto property in multi-line as shown below.

public string Name
{
    get; set;
}

Read more