Go to content Go to navigation Go to search

Basic SQL Statements

December 8th, 2008 by Gabriel

Basic SQL Statements :

SQL is used to query the database which are almost same for SQL Server, MS Access, Oracle and MySQL.
There are four types of basic queries :-

SELECT
INSERT
UPDATE
DELETE
ORDER BY

Different combination of parameters can be passed to a query.

1] SELECT :-

its the most common SQL statement using which data can be selected from database and the output is returned to user.The result is

stored in a result table, called the result-set.SQL is not case sensitive. SELECT is the same as select.
Here is a simple example -

select name, bdate from user;
this will return all names and bdates from the table user.

select * from user;
this will return all records of user table.

select * from user where name=’john’;
this will return all records in which name = john

select * from user where name=’john’ OR name=’paul’ OR bdate=01012007
this way you can add multiple filtering using “OR” , “AND” clause.

2] INSERT :-

it is used to take the data input from user and insert it into table of the database. Data can be taken from any form or it can be

directly inserted using query.It is used to insert a new row in a table.
Simple example-
Insert into Table1 (FirstName, LastName, Phone) Values (’Gabriel’, ‘R’, ‘1112222′);

3] UPDATE :-

Using Update, we edit / modify any exisiting table. Either all the rows can be updated, or a subset may be chosen using a condition.
Simple example -
Update Table1 Set name=@FirstName, LastName=@LastName, Phone=@Phone where id=@ID

WHERE clause us very important in Update query. If you don’t use WHERE then it will update all existing records in the table.

4] DELETE :-

It is used to delete rows in a table. It also uses WHERE claue. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted.
Here is an example of a Delete statement-

Delete From Table1 where ID=10

it will delete all records in which ID = 10

5] Order By Clauses :-

It is used to sort the output returned by a query. Using this clause, you can sort by any field in the table.
Example -
Select * from Table1 Order By name

This will list all returned records sorted by Name alphabetically.

‘ASC’ (ascending order) or ‘DESC’ (descending order) can be included in Orderby query to sort the output in ascending or descending order respectively.
Like -

Select * from Table1 Order By name DESC

New features in Microsoft SQL 2005

October 14th, 2008 by Gabriel

Following are few of the new features and improvements introduced in Microsoft SQL 2005

Manageability :-

SQL Server 2005 makes it easy to deploy, manage, optimize data.
A single integrated management console enables database administrators to easily monitor and manage distributed data.It provides an extensible management infrastructure that can be easily programmed using SQL Management Objects.

SQL Server Management Studio :-

SQL Server Management Studio is a new database management tool for database administrators, developers and end users. It combines the functionality of Enterprise Manager and Query Analyzer. It allows management and authoring for SQL Server 2005 Reporting Services (SSRS), Integration Services, Notification Services, replication, and previous versions of Microsoft SQL Server, all through the same interface.

Enhanced Query Authoring :-

SQL Server 2005 introduces Query Editor which is integrated into SQL Server Management Studio. Query Editor also allows you to write and execute scripts such as multidimensional expressions (MDX), data mining expressions (DMX) and XMLA. Its nothing but the replacement for SQL Server 2005 Query Analyzer.

Security :-

SQL Server 2005 makes significant enhancements to the security model which is already explained at-
http://winadmin.co.uk/microsoft-sql-server/security-features-in-sql-server-2005/

Integration Services :-
SQL Server 2005 includes Integration Services (SSIS) which enables organizations to more easily integrate and analyze data from multiple heterogeneous information sources. By analyzing data across an array of operational systems, organizations may gain a competitive edge through a holistic understanding of their business.