DROP IF EXISTS (DIE) – New in SQL Server 2016

Guys, welcome to the “New in SQL Server 2016” series. In this post, I will be discussing “DROP IF EXISTS (DIE)” command.

DROP IF EXISTS (DIE): Small but convenient language enhancement. This is mainly used when need to drop an object to test before its existence before deleting it i.e. CONDITIONAL DROP STATEMENT.

IF OBJECT_ID ('dbo.student','U') IS NOT NULL
DROP TABLE dbo.student

From SQL Server 2016 CTP3 DIE can be used


If the object does not exist, DIE will not fail and execution will continue. Currently following objects can DIE:

  • ROLE
  • RULE
  • VIEW

DIE can also be added on columns and constraints in ALTER TABLE statement


In the upcoming posts, I will be discussing –

  • Stretch DB

Article by – Kanika Mehra

Constant arrays | Create constant arrays in C#

Fun behind the constants array, is you can’t create it, because you can apply constant only a local values.  However there is certain work around. Instead of constant array you can declare read only array, but all depends upon the requirement that you have.

In my case I wanted to declare a static array those values should not be reassigned, I can achieve this with the help of static read only array
private static readonly string[]constArray ={  "val1", "val2", "val3"};

Here my array will be initialized first before use.  But it is not advisable.

>> Click here to Read the complete Article

Use of Non Abstract Method of Abstract Class in C#

You can have non abstract method in abstract class; as such I didn’t find any use of these methods. Yes this is an option. May be it is useful in some situations when you want to call those methods inside your abstract methods.

As per abstraction rules, you cannot create the object of abstract class, means you cannot use the "new" keyword.

You can create any class as an abstract class with the help of “Abstract” keyword; even you can create any method as an abstract method inside the class. Abstract class can have both type of method “Abstract” & “Non Abstract”. You can inherit these classes inside the non abstract classes.
Abstract classes cannot have the implementations details of abstract methods.

>> Click here to Read the complete Article

DataGrid In CSharp

If you are new to ADO.Net please visit our Ado.net section:

This is very flexible and popular control in Asp.net. We can use this tool to display data in Web/Windows environment.  It helps developers to develop a data driven application in .Net. It allows relationship; we can create relationship on the fly. We can update, delete our data at runtime.  Datagrid has some essential features like Sorting & Pagination. Sorting enables user to sort any columns and paginations helps grid in faster loading of data. User can navigate from one page to another. You can set the size of per page(How many records you want to display in one go).

>> Click here to Read the complete Article

Collection Initializers in C# 3.0 | Basic Tutorial

Collection Initializers is a new concept introduced in C# 3.0.  By implementing this concept in your code you can save your time for initializing individual property of your class.  In C# 2.0 you can initialize a collection you can use the following syntax.

>> Click here to Read the complete Article

How to Access and create XML Web Services in C Sharp

Web service is very important, we can create web services using .Net either C# or VB.net or any .Net supported languages. Web Services are platform independent and can be used remotely.  If your OS supports to HTTP protocols then web services can be consumed by any program so they are platform independent we can say.  To understand the web service you must have at least basic knowledge of C Sharp or any programming language and Ado.net.

In .Net framework we can create two types of Web service
  1. Xml Web services: which are used by normal programs and
  2. Web Services of Remoting.

>> Click here to Read the complete Article

C# 3.0 Automatic properties

Automatic Property:
It’s a new feature in Asp.net. It was introduced with asp.net 3.5.  Prior to 3.5 it was mandatory to declare private variable of a property to hold the value. For example if you  have one property with the name of “YourName” in your class then prior to declare this property you have to have declare one private variable of the same data type which will hold the property value. See the below code

>> Click here to Read the complete Article

Multithreading in C Sharp – Basics

Multithreading is made up with the conjunctions of two words Multi + threading = Multithreading.

Multithreading enables the multitasking & multiprocessing. It means you can run many program asynchronously or concurrently. Let me explain the meaning of threading because I am sure you all are aware of the English meaning of the word “Multi”. So thread is defined the execution path of your program. In terms of computer science thread is a smallest unit of processing.  You can divide a complex task into small sub task those are known as threads for example, OS manage different threads.

For example you can write something on word, simultaneously you can give instructions to print, and the same time you can chat with your friends. These all are possible by threads, you can write multiple threads to execute different actions in you program. In Multithreading helps to execute different process at the same time, it saves lots of time and increase the performance also. As we knows in .Net threads are running inside the App domain. Each app domain started a single thread but you can create other threads from the single threads.

In C#(.Net) you can use “using System.Threading” namespace to enable the multithreading. It contains important features such as

>> Click here to Read the complete Article

C# events and event handlers

What are Events in C#: In simple terms event means happening or action or occurrence of anything. Event can be anything it can be mouse click, enter key press, lost focus. In other words they are the notification, means something is going to change or ready to happen. Handling of the event is known as response. for example when you click on a button another page opens, here button click is an event and second part is the response of that events.  When events happens a notification sent to client so that client can prepare the response.


>> Click here to Read the complete Article

Dataset in C#

Must Read: ADO.net Tutorial for beginners

It is the main core feature of ado.net. Ado.net has two main components as Dataset and Data Provider. It persists data in memory which is separately from the database. By nature it is disconnected. You can perform all DML statement. You can load data in dataset from any data source like SQL Server, Oracle etc. You can create table inside the Dataset even you can define the keys and create relationship between them.  It belongs to “System.Data” namespace.

How to Declare Dataset in C#

>> Click here to Read the complete Article