Wednesday, 11 January 2017

SQL Select Statement.?

The SELECT Statement is used to fetch the data from Database.

Select statement is used to select data from database.
The Result is stored in a Result Table, called Result-Set.

SQL Select Statement
SELECT ColumnName1, ColoumnName1 From  TableName;
OR
Select  *  from TableName ;

Example:=-
                  Table Name -  Student
id               Name         Age         Gender
 1                Ram            15              Male
 2                Bob             18             Male
 3                julie            18            Female
4                  john           22              Male


Write Query:-  Select * from Student;
OutPut 
 id               Name         Age         Gender
 1                Ram            15              Male
 2                Bob             18             Male
 3                julie            18            Female
4                  john           22              Male

 Write Query:- Select id, Name, Age From Student Where id= 1;
Output
 id               Name         Age        
 1                Ram            15         



Comments in SQL.

Comments can be used to explain section of statements.

Single Line Comments

-----Select All data from database Table
Select * from  TableName.

Multi Line Comments

/* Select all column form the database table*/
Select * form Tablename

Note:- Here TableName is our TableName like Student,Employee
"SQL Tutorial"

What is SQL.?

SQL is a standard language for accessing databases.
Our SQL tutorial will teach you how to use SQL to access and manipulate data in: MySQL, SQL Server, Access, Oracle, Sybase, DB2, and other database systems.

What is SQL Server.?
SQL Server is a relational database management system (RDBMS) from Microsoft that's designed for the enterprise environment. SQL Server runs on T-SQL , a set of programming extensions from Sybase and Microsoft that add several features to standard SQL, including transaction control, exception and error handling, row processing, and declared variables.

Use of SQL.?
  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL can insert records in a database
  • SQL can update records in a database
  • SQL can delete records from a database
  • SQL can create new databases
  • SQL can create new tables in a database
  • SQL can create stored procedures in a database
  • SQL can create views in a database
  • SQL can set permissions on tables, procedures, and views
 Example:- Select * from TableName

Commands in SQL.?
  • SELECT - extracts data from a database
  • UPDATE - updates data in a database
  • DELETE - deletes data from a database
  • INSERT INTO - inserts new data into a database
  • CREATE DATABASE - creates a new database
  • ALTER DATABASE - modifies a database
  • CREATE TABLE - creates a new table
  • ALTER TABLE - modifies a table
  • DROP TABLE - deletes a table
  • CREATE INDEX - creates an index (search key)
  • DROP INDEX - deletes an index


 

NOCOUNT In SQL Server This Statement is used to stop the message that shows the count of the number of rows affected by the SQL statement...