Comparing Linq and SQL

Prove you're a Dev Guru! Take the test now!

Linq ('Language Integrated Query') is a Microsoft programming model that adds formal data querying capabilities to .NET-compliant languages. You can project, filter and traverse data in arrays, enumerable classes and relational databases using native .NET language syntax for queries. To see Linq at work, take a look at the following example:

using System;

using System.Linq;

using System.Collections.Generic;

class MyLinqApp


static void Main()


string[] myData = { "Microsoft", "IBM", "Intel", "Sun Microsystems", "AMD" };

IEnumerable myLinqQuery = from data in myData

where data.Length

orderby data

select data.ToUpper();

foreach (string data in myLinqQuery)




The output of this program will be



SQL ('Structured Query Language') is the most common database language. SQL helps in retrieval, insertion, updating and deletion of data from relational databases like SQL Server and Oracle.

For example, consider the following SQL query for selecting data from a table:

Select Name, Age, BirthDate From Person where Age > 40

This query will fetch Name, Age and BirthDate of all the persons from the table Person, whose age is greater than 40.