SQL

 Creatinga database from a .bak file


In this post I am going to explain about how torestore a database from the .bak file.It is very simple.
Do the following things :
1)Open the Sqlserver 2005/2008 and Right click on the Databases  and select the “Restore DataBase” option.
2)Type the Database name and select the path of the file where your database is existed in your system.
3)If you click the button it will open the following screen .Click add button and select the file of .bak.
4)After adding check the box in the select the backup sets to restore section.
5)On the Left top side you able to find the “Options” please click it. And check the overite the database check box and then click ok . your Data base will created in your local Server. More ..
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@



In this post I am going to explain about the How to create a “Stored procedure with output variable” and How to use this kind of stored procedures in the c#.
Let us create a sample table called Tbl_Employee with the following Data More..

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

The Group By clause is used to grouping or to priovide summary data for column returned in a SELECT statement.It Groups a selected set of rows into a set of summary rows by the values of one or more columns or expressions in SQL.
GROUP BY Clause is used with SELECT Command, and specifies the groups into which output rows are to be placed by the values of one or more columns or expressions.  And if aggregated functions are used in the SELECT statements, then GROUP BY clause computes a summary value for each group.  More..

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 
Finding Highest Salary from Employee Table in SqlServer :
In many interviews mainly freshers and 2to 3 years of experience we will Face a question called finding  the nth highest salary from employee table. More..

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 

Setting auto  increment column / Identity column  on the column in SQL SERVER 2008
To Insert the unique values in the table we will use the Auto increament column on the table.It will generate automatically unique number for newly insert in table .

Method 1 :
Open SQL server  2008 and connect to local server  >> Click on Data Bases >> Click on the Database you want to create a table >> click on Tables >> Right click select New Table (It will open the New Table design mode as shown in the figure) >> Create a Table With your desired column with first column as Identity column.The Identity column data type must be int. More ..

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Joins in SqlServer 

Join :Suppose If we want to retrive the Data from two or more tables we are using the "Joins" concept.

Inner Join:  The INNER JOIN keyword return rows when there is at least one match in both tables.This join returns rows when there is at least one match in both the tables.

LEFT JOIN ( Left Outer Join): The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2). More ...