What are TRIGGERS in SQL - Server

We are going to discuss about TRIGGERS in SQL – SERVER in this article. Triggers are very important in enterprises level database management. You have to understand following table: This command will create a table on which we will apply triggers: 1. Create table Staff(id int NOT NULL PRIMARY KEY IDENTITY(1, 1), name varchar(55), email varchar(55)); 2. Create table Log_Audit(id int NOT NULL PRIMARY KEY IDENTITY(1, 1), StfId int, StfName varchar(50), StfEmail varchar(50), AuditAction varchar(50), AuditTime datetime); Fill your Staff table with the following data: 1. Insert into Staff(name, email) select ‘Rajat’, ‘rajat@example.com’; 2. Insert into Staff(name, email) select ‘Anjali’, ‘anjali@example.com’; 3. Insert into Staff(name,Read More →

Explain the number of ways in which a parameter can be passed to a method ? Parameters can be passed to a method in following three ways : Output Parameters − If the goal is to return more than one value. Value Parameters − In This method the actual value of an argument is copied into the formal parameter of the function. If changes are made to the parameter inside the function there is no effect on the argument. Reference Parameters − The reference to the memory location of an argument is copied into the formal parameter.Argument is affected by the alterations made to theRead More →

Arrays of characters is a good example to explain Strings in C#.  But actually Strings are Objects in C#. While declaring a string variable, an object of type “String”  is  instantiated. Various useful properties and methods are supported by String objects. Some examples are given below: Length –  To get the length of a string. Insert(index, value) To insert the desired value into the string where the stating / indexing point is specified.  IndexOf(value) to get the first index of the first occurrence of the value within the string. Remove(index) to remove all characters in the string after the specified index. Replace(oldValue, newValue) to replaceRead More →

To understand what encapsulation means, it can be considered as “surrounding” an entity, to keep and protect whatever is inside the surrounding. It has a similar concept in programming as well, here encapsulation has a wider meaning than combining the members together within a class; it has a function of access restriction to the inner workings of that class as well. Access modifiers implements Encapsulation. An access modifier defines the scope and visibility of a class member. Encapsulation is also termed as information hiding. C# supports the following access modifiers: public, private, protected, internal, protected internal. Example of Encapsulation : class Account { private doubleRead More →

A method that calls itself is called a recursive method. Calculating the factorial of a number is One of the tasks that can be solved using recursion. In Maths,  Factorial of a number x is denoted as x! and it is : For example:5! = 5*4 * 3 * 2 * 1 = 120 It concludes that the factorial of any number can be calculated using number x number-1 and such that : number-1 reaches “1”. We can define our method based on the above conclusion and statement : static int Factorial(int number) { if (number == 1) { return 1; } return number *Read More →

Useful Methods to Return values in Arrays Here are the available methods to get values in an array. Max returns the largest value. Min returns the smallest value. Sum returns the sum of all elements. Examples : Let’s consider this array : int[ ] arr = { 2, 4, 7, 1}; Console.WriteLine(arr.Max()); //Outputs :  7 Console.WriteLine(arr.Min()); //Outputs : 1Console.WriteLine(arr.Sum()); //Outputs : 14Read More →

Many operators in C# can be overloaded, it means that they can be redefined for custom actions. For example, you can redefine the action of the plus (+) operator in a custom class. Consider the Box class that has Height and Width properties: class Box { public int Height {get; set;} public int Width {get; set;} public Box(int h, int w) { Height = h; Width = w; } } static void Main(string[] args) { Box b1 = new Box(14, 3); Box b2 = new Box(5, 7); } We would like to add these two Box objects, which would result in a new, bigger Box.Read More →

Here lets create an array of Fruits (of same data type string) Name of Our Array is mystrArray and it has 5 elements.   string[] mystrArray = new string[] { “Apple”, “Banana”, “Grapes”, “Mango”, “Pine-Apple” };   // Reading array items using foreach loop foreach (string mystr in mystrArray) {     Console.WriteLine(mystr); } A loop will iterate through all the elements in the string and Print them one by one as we are referring to Each element of the array. Foreach loop is very handy when the requirement is to fetch multiple rows of records from a database.Read More →

C# has  various classes that are built-in and they can store and manipulate data. An example of such a class is the Array class. In order to store a collection of data the data structure that is used in C# is known as array. It can be described as a collection of variables of the same type. Let’s assume a situation where you need to store 250 numbers. One option is to declare 250 different variables but a smarter solution is to declare an array that stores 250 elements. To declare an array, specify its element types with square brackets: int[ ] yourArray; This isRead More →