Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
SQL

Featured

SQL Server : How to Enable or Disable All the Triggers on a Table and Database?

Sometimes we need to disable trigger on a table especially when performing admin tasks on a table. Following commands provide a quick way to disable all the triggers for a table. Please note that when we are diabling triggers on a table we w...

SQL Server : How to do case sensitive search?

Sometimes during application development we need to do case sensitive search. Let us see how we can do the same in SQL Server. For illustration purpose we will use a table called Technology which has a column named Platform.Now let us say colu...

NORMALIZATION IN DBMS

NORMALIZATION Database is a collection of meaningful data by which we can easily upload,update,delete and manage data. while creating a database the main problem which encounter is data redundancy. Data redundancy is condition in which same ...

Truncating a table

TRUNCATE TABLE Statement: TRUNCATE Statement is used to remove all records from a table. It is a Data Definition Language (DDL) Statement as it deletes all records and only structure remains. It is similar to delete statement but without where...

Null Values

Null Values: Null values denotes missing data in a table or a database. If a column does not have any NOT NULL constraint then for that column there can be NULL values. By default a column can have NULL values. We cannot use comparison oper...

SQL : How to update top N records in a table?

It is a common requirement in SQL server development to update top N records in SQL server.In this blog we will see two approaches to accomplish the same. 1) Using UPDATE with TOP UPDATE TOP (100) Table1 SET field1 = 1 However witho...

SQL Server : Error handling using TRY-CATCH

Before SQL Server 2005, the only practical way to trap errors in SQL was using the old-fashioned @@error system variable. Although this is still supported, in this blog we will learn how to use TRY-CATCH for handling errors.TRY-CATCH block is si...

SQL Server Transactions

A Transaction groups a set of tasks into a single execution unit. Each transaction begins with a specific task and ends when all the tasks in the group successfully finish.If all of these tasks execute successfully, then a transaction is committe...

Change the datatype of a column in SQL Server

Hello Reader!If you wish to add, delete or modify columns in an existing table you can do this with the help of ALTER command. The syntax to change or we can say to modify a column in an existing table in SQL server is: ALTER TABLE table-na...

SQL LIKE Clause

The SQL like clause is used to look for the values which are similar to the values in the table with the help of wildcard operators. We have two types of wildcard operators: 1. "% - percent sign 2. _- underscore Syntax: SELEC...

Combining Results of two or more SELECT Statements

Combining Results of two or SELECT Statements using UNION OPERATOR: UNION Operator is used to combine the results of two or more SELECT statements. But UNION operator does not return duplicate rows so to return duplicate rows UNION ALL operato...

SQL: Difference between inner join and outer join

Joins are used to combine the data from two tables and return specific rows of data from the tables. A join can be either an inner join or an outer join, depending on what is expected in the result. INNER JOIN: Gets all matching rows i...

Sub Queries

Sub Queries: Sub Queries are those query which comes within another query and are written after the WHERE clause.They are also known as Inner query or nested query. It is used to return records that are used in the main query as a conditio...

DELETE Query

DELETE Statement: It is used to delete existing records from a table. It can delete all records from a table if where condition is not given and if where condition is given than it will delete selected records which will meet the condition. ...

Having Clause

Having Clause: The Having clause is used to filter the group result. As we cannot use Where to filter the Group By clause results so Having provide the same functionality as Where. It filter the result fetched by Group By clause. It comes a...

SQL commands in database

SQL stands for structured query language. It is used to manage and access data from database. A database may contain more than one table having unique name for each table. SQL language have many different versions but it supports most of the co...

Group By Statement

Group By : It is used to group the result-set by one or more column. It is used in conjunction with aggregate functions provided by Structured Query Language . If order by is used then Group By must come before Order By clause. Syntax1: ...

Crreating Virtual Table using CREATE VIEW statement

CREATING VIEWS: Views are virtual tables which are created from other tables .It is beneficial for those situation when we want to show limited columns to users. It can be created from one or more tables. Syntax: CREATE VIEW viewname AS ...

Pattern Matching Using Like Operator

LIKE Operator: It is used to search for pattern in a table or a database . It is used with where condition. It is similar to REGEXP of MySQL. Syntax: SELECT columnname(s) FROM tablename WHERE columnname LIKE pattern-condition; Examp...

Updating a column value

Updating a column value using Update Statement: UPDATE statement is used to change the value for a column or to change multiple records using a condition. It is a data manipulation language command which are used for managing data. Syntax: ...

To add a primary key using ALTER command

Adding a primary key using ALTER Command: Alter command is generally used to modify table . It can be used to add columns or to remove columns. Using Alter command we can also add or remove a key from a table. Syntax: ALTER TABLE tablena...

To check the structure of a table

DESCRIBE Statement: It is used to view the structure of a table means it shows name and data type of columns. Syntax 1: DESC tablename; Syntax 2: DESCRIBE tablename; Example: DESC Employee; Column Datatype ...

what is the use of FORMAT() function in SQL?

In SQL, FORMAT() function is used to format a column value means how a field will to be displayed. FORMAT() Syntax SELECT FORMAT(column_name,format) FROM table_name; In the above syntax parameters are as below: Parameter Descri...

what is the use of NOW() function in SQL?

In SQL, NOW() function is used to return the current system date and time. NOW() Syntax SELECT NOW() FROM table_name; We have a table "employee" as below: employee id first_name last_name salary ........

SQL Tutorial -> Sql Inner Join

<-- Chapter 25: SQL Join Chapter 26 SQL Inner Join SQL Inner Join clause is used to fetch all the rows from more than two tables in which there is a match between the columns. Inner Join is similar like Join clause. Lets see an ...

SQL Tutorial -> Sql Joins

<-- Chapter 24: SQL Aliases Chapter 25 SQL Joins SQL Joins clause are used to combine data rows from two or more than two tables according to common field values between them. Lets see an examples from the below tables "customer...

Inserting data using replace statement

REPLACE INTO Statement: It is used to insert a row in a table.It is similar to INSERT INTO statement but it does not allow duplicate row as it replaces the old one with the new one. Syntax: REPLACE INTO tablename (column1, column2, col...

SQL: WHERE ,AND and OR Clause

1. SQL WHERE Clause:- SQL WHERE Clause is one of the most useful feature of the SQL query as it is used to specify a condition while fetching the data from single table or joining with multiple tables,it also allows you to select specific ...

Eliminating Duplicates using Distinct Keyword

DISTINCT Keyword: It is used to fetch different values from a table. It removes duplicate records from the result set and used when there can be multiple duplicate tuples in a table. Syntax: SELECT DISTINCT columnname FROM tablename; ...

SQL Tutorial -> Sql Wildcards

<-- Chapter 22: SQL Select Top Chapter 23 SQL Wildcards SQL Wildcard characters are used to substitute any characters in a string. As we have discussed LIKE operator in chapter 10. SQL supports two wildcard operators with LIKE opera...

ALIAS Keyword

ALIAS Keyword: It is used to give temporary names to table and columns. It is very useful for situations where column or table names are too long. Synatx: SELECT columnname AS alias&#95;name FROM tablename; This syntax is used ...

SQL Tutorial -> Sql Injection

<-- Chapter 20: SQL DELETE Chapter 21 SQL INJECTION SQL Injection is an injection attack wherein attacker is able to submit a database SQL command which is executed by a web application exposing back-end database. Attacker can add SQL ...

SQL Tutorial -> Sql Update

<-- Chapter 18: SQL INSERT Chapter 19 SQL UPDATE UPDATE statement is used to update existing table data in database table with the help of WHERE clause.WHERE clause tells which record is to be updated. Lets see an example from the b...

SQL Tutorial -> Sql Insert

<-- Chapter 17: SQL ORDER BY Chapter 18 SQL INSERT INSERT INTO is the SQL Statement used to insert data in database table in the form of rows and columns. Lets see an example from the below table "employees" :- employee_id ...

SQL Tutorial -> Sql ORDER BY

<-- Chapter 16: SQL And & Or Chapter 17 SQL ORDER BY ORDER BY is the keyword used to sort the database table data by one or more columns. ORDER BY sort the Records in Ascending order by default. To sort the Record in Descending Ord...

SQL Tutorial > Sql <= Operator

<-- Chapter 14: SQL >= Operator Chapter 15 SQL <= Operator Lets see an example from the below table "employees" :- employee_id name code designation salary 101 ABC E-101 Engineer 12000 102 DEF E-1...

SQL Tutorial > Sql >= Operator

<-- Chapter 13: SQL < Operator Chapter 14 SQL >= Operator Lets see an example from the below table "employees" :- employee_id name code designation salary 101 ABC E-101 Engineer 12000 102 DEF E-10...

SQL Tutorial -> Sql < Operator

<-- Chapter 12: SQL > Operator Chapter 13 SQL < Operator Lets see an example from the below table "employees" :- employee_id name code designation salary 101 ABC E-101 Engineer 12000 102 DEF E-102...

SQL Tutorial -> SQL BETWEEN Operator

<-- Chapter 10: SQL LIKE Operator Chapter 11 SQL BETWEEN Operator Lets see an example from the below table "employees" :- employee_id name code designation salary 101 ABC E-101 Engineer 12000 102 DEF E-...

SQL Tutorial -> Sql LIKE Operator

<-- Chapter 9: SQL != Operator Chapter 10 SQL LIKE Operator Lets see an example from the below table "employees" :- employee_id name code designation salary 101 ABC E-101 Engineer 12000 102 DEF E-102 D...

SQL Tutorial -> Sql NOT IN Operator

<-- Chapter 6: SQL IN Operator Chapter 7 SQL NOT IN Operator Lets see an example from the below table "employees" :- employee_id name code designation salary 101 ABC E-101 Engineer 12000 102 DEF E-102 ...

SQL Tutorial -> Sql Where

<-- Chapter 4: SQL Distinct Chapter 5 SQL Where SQL Where : SQL Where clause extract or filters those records which matches the specified condition. Syntax for Where clause is used below SELECT * FROM tablename WHERE condition ...

SQL Tutorial -> Sql Distinct

<-- Chapter 3: SQL Select Chapter 4 SQL District SQL District : District is a keyword which is used to fetch unique column values from database table OR we can simply say that ignores the column duplicate values. Syntax for district ke...

ORDER BY Clause

Sorting the result using Order By clause: ORDER BY clause is used to sort the data fetched using select statement either in ascending order or in descending. By default data fetched is sorted in ascending order. Syntax: Select columnname...

SQL Tutorial -> Sql Select

<-- Chapter 2: SQL Syntax Chapter 3 SQL Select SQL Select : SELECT command describes that through which we can fetch data from MYSQL database tables OR we can say, It is used to retrieve/select data from MYSQL database. SELECT comma...

SQL : How to get last N records based on ordering of a specific column in SQL Server ?

Sometimes we may be required to get the get last N records of a table in SQL server based on ordering on a specific column . In this post we will create a query to get the result. First let us create a table which we will use in our query. CR...

SQL : How to reset identity seed after deletion of records in SQL server ?

By using the seed value for every new record Microsoft SQL Server's identity column generates sequential values. In this post we will learn how to reseed an identity column. Following is the command to reset the identity property : DBCC C...

SQL : How to get column names of a table in SQL Server ?

Often we may be required to get the names of all columns in a table in SQL server. In this post we will see the different options available in SQL server to fetch the column names. 1) We can use the below query to get the column names. SELE...

SQL : How to Delete using INNER JOIN in SQL Server ?

In this post we will see how to use JOIN for deleting data from SQl server table. Let us first create tables which we will use for understanding the deletion process using JOINS. -- Create table1 CREATE TABLE #Table1 (Col1 INT, Col2 VARCHAR(5...

SQL : How to check if a stored procedure exists before creation?

In this article we will learn how to check if a stored procedure exists before creating it. We can use the below script which will drop the proc if it exists and then recreate it. IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name...
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: