Showing posts with label Interview Question. Show all posts
Showing posts with label Interview Question. Show all posts

Wednesday, June 16, 2021

What are triggers in sql server?

 A trigger is a special type of stored procedure that automatically run when an event occurs in the database server. 

Types of Triggers:-

There are three types of triggers in sql server.

  • DML Triggers
  • DDL Triggers
  • Logon Triggers
DML triggers run when a user tries to modify data through the Data Manipulation Language(DML) event. DML event are INSERT, DELETE or UPDATE statement on a table or view. These triggers fire when any valid event fires, whether table row affected or not.

DDL triggers run in response to a variety of Data Definition Language(DDL) events. DDL event are CREATE , ALTER or DROP Statements.

Logon triggers fires in response to the LOGON event that’s raised when session is being established. 
 



Friday, October 23, 2020

Difference between Trim() and Replace() in c#

 Trim removes all whitespace characters from the beginning and end of the string. that means spaces, tabs, new lines, returns and other assorted whitespace characters.


Replace() only replaces the designed characters with given replacement. so replace(" ", string.empty) will only replace space with empty string. replace also

Replace all instances of the designated string with the given replacement not just those at the beginning end of the string.

String.Replace will remove all (and only) space characters, and string. Trim will remove all whitespace characters from the beginning and the end of the string not once int the middle.

Example:

var tmp=" hello world \t";

var res1=tmp.trim(); //output is hello world

var res2=res1.Replace(" ",String.empty); // helloworld





Thursday, December 19, 2019

Difference between Delete, Drop and Truncate in SQL Server


Delete is used to delete the one row or more than one rows or all rows from data table in database.

Syntax:
DELETE FROM TABLE table_Name;

After execute this query all rows are removed from table.

DELETE FROM TABLE table_Name WHERE column_Name=?

After execute this query particular row removed from table.

Drop is used to delete whole database or just a table.
The Drop statement destroys the objects like an existing database,table,index,or view.

Syntax:
DROP object object_Name

Examples:
DROP TABLE table_name;
table_name: Name of the table to be deleted.

DROP DATABASE database_name;
database_name: Name of the database to be deleted.

Truncate statement is a Data Definition Language(DDL) operation that is used to mark the extents of a table for deallocation (empty for reuse).

Truncate basically used to remove the whole data from table but remain the structure of table for future use.

Syntax:

TRUNCATE TABLE table_Name;

TRUNCATE Vs DROP
Truncate is normally ultra-fast and its ideal for deleting data from a temporary table.
Truncate preserves the structure of the table for future use, unlike drop table where the table is deleted with its full structure.
Table or Database deletion using DROP statement cannot be rolled back, so it must be used wisely.

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...