In SQL data types are four types. String,Numaric,Date/Time and large data types. following table contain all data types used in SQL. majar data types string numaric date and time large see more information plz visit
The ISNULL function checks an expression for a NULL value and replaces it with a specified replacement value. select birthdate, isnull (birthdate,from '01/04/12')as and newdate from employees where employeeid =10 see more information plz visit
A view is something of a virtual table. A view, for the most part, is used just like a table, except that it doesn’t contain any data of its own. The difference between a view and a table is that views are definitions built on top of other tables (or views), and do not hold data themselves. Instead, a view is merely a pre planned mapping and representation of the data stored in tables. You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from one single table. create view productlist
The ALTER TABLE statement allows changing the structure of a table after it has been created. New columns can be added with the ADD clause. Existing columns may be removed from a table using the Drop clause. alter table emploeeys add salary int see more information plz visit
The SQL DROP command is used to remove an object from the database. If you drop a table, all the rows in the table is deleted and the table structure is removed from the database. Once a table is dropped we cannot get it back, so be careful while using RENAME command. When a table is dropped all the references to the table will not be valid. Drop table employee see more information plz visit
CHECK constraints are that they are not restricted to a particular column. They may also check that any combination of column values meets a criterion. The constraint is defined using the same rules that you would use in a WHERE clause. Once the check defined, the database will only insert a new row or update an existing row if the new value satisfies the CHECK constraint. The CHECK constraint is used to ensure data quality. create table employees ( imployeeid int check(employeeid >0) Lname nvarchar(20), Fname nvarchar(20) ) see more information plz visit
Foreign keys are both a method of ensuring data integrity and a manifestation of the relationships between tables. When you add a foreign key to a table, you are creating a dependency between the table for which you define the foreign key (the referencing table) and the table your foreign key references (the referenced table). The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables. create table orders ( orderid int primary key, orderdate datetime , employeeid int refrences employees(employeeid) ) see more information plz visit
Primary keys are the unique identifiers for each row. They must contain unique values (and hence cannot be NULL). Because of their importance in relational databases Primary keys are the most fundamental of all keys and constraints. A table can have a maximum of one primary key. A primary key can consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key. create table employee { empid int primary key, empname varchar(20), empLname varchar(20), } see more information plz visit
Once you establish a uniqueconstraint, every value in the named columns must be unique. If you go to update or insert a row with a value that already exists in a column with a unique constraint, SQL Server will raise an error and reject the record. create table employee { empid int unique, empname varchar(20), empLname varchar(20), } see more information from visit
This one is pretty simple it states whether the column accepts NULL values or not. When you specify NotNull attribute to column then u cannot give null vale to column or set column as null. create table emloyee { empid int notnull, empname nvarchar(20) notnull, empLname nvarchar(20)notnull, } see more infromation from plz visit
This is the main container for holding data in the database. It can be created through following command. create table employee { empid int, empname varcahr, emllaname varchar, } Result of this command is to make new object for storing of data name dumyTable. see more information plz visit
Create Database means to create new object for storing data of particular thing. As describe in Syntax. create <objecttype> <objectname> create database dumydatabase see more information plz visit
union is a special operator we can use to cause two or more queries to generate one result set. All the union queries must have the same number of columns in the SELECT list. Data type should be same of columns in select queries. By default union operator result is distinct which means same data in column will eliminate. select employeename from empoyee union select suppliername from suppliers see more information plz visit
full join are used to all record retrive from tow table .full join retrive data from both side right and left
from the table .full join used for the matching pattern.
select * from employeename
from employee
full join manager
on employee.name =manager.name
A CROSS JOIN differs from other joins in that there is no ON operator, and that it joins every record on one side of the JOIN with every record on the other side of the JOIN. In short, you wind up with a Cartesian product of all the records on both sides of the JOIN. The syntax is the same as any other JOIN except that it uses the keyword CROSS (instead of INNER, OUTER), and that it has no ON operator. select * from employeename from employee cross join manager see more detail plz visit
outer joins are, as we have said, inclusive in nature. What specifically gets included depends on which side of the join you have emphasized. A left outer join includes all the information from the table on the left. select employename from employee left joint manager on employee.hussain=manager.shahzad
And a right outer join includes all the information from the table on the right. Let’s put this into practice with a small query so that you can see what I mean.
select employename from employee right joint manager on employee.hussain=manager.shahzad see more detail plz visit
Inner joins are far and away the most common kind of JOIN. They match records together based on one or more common fields, as do most JOINs, but an INNER JOIN returns only the records where there are matches for whatever field(s) you have said are to be used for the JOIN. select employname from employee inner join managername on employee.employname=manager.managername see more plz visit
Between used in where clause select range of data between values. Between is used in that scenario when we want to retrieve data between 2 record or data. Use Between Key word select * from employees where Lastname Between 'shahzad' and 'samejo' see more detail plz visit
Like operator used for pattern matching.and Like operator is used in where clause. select * from employee where lastname like "%u%" see more detail plz visit
Top key word used to retrieve desired no of rows when table contain hundred or thousand of data. select top * from employee Or select top * from employee see more detail plz this link