1. Swap with the help of temporary variable:
-------------------------------------------------
DECLARE @temp AS varchar(10) UPDATE Employee1 SET @temp=LastName, LastName=FirstName, FirstName=@temp
2.directly:
------------ UPDATE Employee1 SET LastName=FirstName, FirstName=LastName |
Sunday, April 28, 2013
How to exchange the data of column in the same table in the Sql server
Wednesday, April 24, 2013
Find N-th salary from employee table
Row Number :
SELECT Salary,EmpName FROM
( SELECT Salary,EmpName,ROW_NUMBER() OVER(ORDER BY Salary) As RowNum
FROM EMPLOYEE ) As A
WHERE A.RowNum IN (2,3)
Sub Query :
SELECT *
FROM Employee Emp1
WHERE (N-1) = (
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary)
Top Keyword :
SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
SELECT Salary,EmpName FROM
( SELECT Salary,EmpName,ROW_NUMBER() OVER(ORDER BY Salary) As RowNum
FROM EMPLOYEE ) As A
WHERE A.RowNum IN (2,3)
Sub Query :
SELECT *
FROM Employee Emp1
WHERE (N-1) = (
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary)
Top Keyword :
SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
Thursday, April 22, 2010
Index Question 23 April 2010
Index Question 23 April 2010
1. Identity columns is index column?
2. Can we use multiple cluster index in sql query? if yes how?
3. what is composite index ?
4. Can an index declared on multiple column ?
5. if a table has already clustered index , can we create primary key on the table ?
6. what is page split?
7. How to rebuild the index?
8. Can we delete an index used by a primary key or unique constraint ?
9. Can we create index on table variable or temporary table?
10. can we create index on system table?
1. Identity columns is index column?
2. Can we use multiple cluster index in sql query? if yes how?
3. what is composite index ?
4. Can an index declared on multiple column ?
5. if a table has already clustered index , can we create primary key on the table ?
6. what is page split?
7. How to rebuild the index?
8. Can we delete an index used by a primary key or unique constraint ?
9. Can we create index on table variable or temporary table?
10. can we create index on system table?
Backup plans Question from Vikram
Question on Backup plans:
1.What is full, differential and transaction log Backup in SQL Server, and how do they interact with each other?
2. How many Recovery model exist in SQL Server, and their role in the Backup strategy?
3. How does the Transaction log backup maintain log space in different recovery models?
4.In which system databases you can not Backup Transaction logs?
5. What is the differential and incremental backup in SQL Server?
6. What is Point-in-Time recovery in the SQL Server?
7. What is Copy-Only Backups feature in SQL Server?
8. Which System databases can not be backed up at all?
9. What is the Tail-end Transaction log backup, and how is it performed?
10. How is file or filegroup Backups helpful for very large databases?
1.What is full, differential and transaction log Backup in SQL Server, and how do they interact with each other?
2. How many Recovery model exist in SQL Server, and their role in the Backup strategy?
3. How does the Transaction log backup maintain log space in different recovery models?
4.In which system databases you can not Backup Transaction logs?
5. What is the differential and incremental backup in SQL Server?
6. What is Point-in-Time recovery in the SQL Server?
7. What is Copy-Only Backups feature in SQL Server?
8. Which System databases can not be backed up at all?
9. What is the Tail-end Transaction log backup, and how is it performed?
10. How is file or filegroup Backups helpful for very large databases?
Wednesday, April 21, 2010
Indexl Question 22 April 2010
- Can we alter the index?
- Which system are used in very large number of indexing system ?
- What happened if the clustered index is not unique ?
- where logged the entry of index in sql server ?
- what is default sorting order of index?
- which constraint is created index by default?
- what is use of DBCC showconfig?
- How to use fill factor with pad? Explain
- Explain hash join and merge join ?
- What is maximum size of row ?
Index Question -21 April 2010
Date: 20/04/2010
1. If a table has not any index column, table is unordered structure, what will say it unordered structure?
2. What is row locator?
3. Can we create non- clustered index, without clustered index?
4. Can cluster and non- clustered index can be unique?
5. What is role of partitions in table and index?
6. How many non-clustered indexes can be in a table?
7. How maintained the index, when table or view is modified?
8. What is spatial index?
9. What type of data type, where we not create the index?
10. Create Index testIndex on(columnname>
What type of index will get created after executing the above statement ?
1. If a table has not any index column, table is unordered structure, what will say it unordered structure?
2. What is row locator?
3. Can we create non- clustered index, without clustered index?
4. Can cluster and non- clustered index can be unique?
5. What is role of partitions in table and index?
6. How many non-clustered indexes can be in a table?
7. How maintained the index, when table or view is modified?
8. What is spatial index?
9. What type of data type, where we not create the index?
10. Create Index testIndex on
What type of index will get created after executing the above statement ?
Subscribe to:
Posts (Atom)