RE: sql server interview questions and answers for experienced
What is the purpose of using SET ANSI NULLS ON?
The purpose of using SET ANSI_NULLS ON to follow the ISO Standard. Acording to this = and <> should not be used for null comparison. Instead we use null and is not null how ever if you will use = null it will return zero rows. If we want to use = or <> for null comparison use SET ANSI_NULLS OFF it means do not follow ISO Standard. SET ANSI_NULLS should be set to ON for executing distributed queries for maintaining compatibility of queries across Servers.
Difference between cluster and non cluster index in sql?
A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.
A non clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
Can we create non primary key as cluster index?
Yes we can do this on non-primary key column but that column must be unique and the primary key column of that table must have non-clustered index because there is one cluster index in table. By default primary key column contains clustered index so its recommended to create such non-primary key clustered index column first and then should create primary key column so in such case the primary key on that column will be with non-clustered. But its highly recommended to create primary key column as a clustered indexed column.
Can we call a Trigger in store procedure?
A Trigger is also a special kind of Stored Procedure which will fire automatically on the happening of an event like before or after insert, update or delete. We cannot call a trigger explicitly from a Stored Procedure.
Difference Between GETDATE and SYSDATETIME?
When we use GETDATE the precision is till miliseconds and in case of SYSDATETIME the precision is till nanoseconds.
Get top two records without Top keyword.
[SQL]
The purpose of using SET ANSI_NULLS ON to follow the ISO Standard. Acording to this = and <> should not be used for null comparison. Instead we use null and is not null how ever if you will use = null it will return zero rows. If we want to use = or <> for null comparison use SET ANSI_NULLS OFF it means do not follow ISO Standard. SET ANSI_NULLS should be set to ON for executing distributed queries for maintaining compatibility of queries across Servers.
Difference between cluster and non cluster index in sql?
A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.
A non clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
Can we create non primary key as cluster index?
Yes we can do this on non-primary key column but that column must be unique and the primary key column of that table must have non-clustered index because there is one cluster index in table. By default primary key column contains clustered index so its recommended to create such non-primary key clustered index column first and then should create primary key column so in such case the primary key on that column will be with non-clustered. But its highly recommended to create primary key column as a clustered indexed column.
Can we call a Trigger in store procedure?
A Trigger is also a special kind of Stored Procedure which will fire automatically on the happening of an event like before or after insert, update or delete. We cannot call a trigger explicitly from a Stored Procedure.
Difference Between GETDATE and SYSDATETIME?
When we use GETDATE the precision is till miliseconds and in case of SYSDATETIME the precision is till nanoseconds.
Get top two records without Top keyword.
[SQL]
set
rowcount 2
select Column1, Column2 from TableName
select Column1, Column2 from TableName
Difference between Set and Select.
-Set is a ANSI standard for variable assignment. It assigns value to only one variable at a time.
-Select is a Non-ANSI standard when assigning variables. It assigns multiple variable at a time.
-When assigning from a query that returns more than one value, SET will fail with an error.
-When assigning from a query that returns more than one value, SELECT will assign the last value returned by the query and hide the fact that the query returned more than one row.
How to get number of Maximum connection can be establish to SQL?
select @@MAX_Connections
Why we use SET ROWCOUNT in Sql?
This syntax is used in SQL Server to stop processing the query after the specified number of rows are returned.
What are the Global Temporary Tables?
We can create global temporary tables but these are not using much in sql an the name of these table start with two pound signs. For example, ##globaltbl is a global temporary table. As the name suggest these table is Global temporary tables and visible to all SQL Server connections. When we create any one of these all users can see it.
What is a View in SQL?
View is just a virtual table nothing else which is based or we can say develop with SQL SELECT query.So we can say that its a real database table (it has columns and rows just like a regular table),but one difference is that real tables store data, but views can''t. View data is generated dynamically when the view is referenced. And view can also references one or more existing database tables or other views. We can say that it is filter of database.
Why Group BY and Order By clause are so expensive?
Both Group By and Order By clause requires Temporary table to process the result of query so these are expensive.
What is the use of SET NOCOUNT ON?
When we use SELECT and DML statement in SQL. SQL server return a message which specify the number of rows effected by these statements. This information helps coder when they are debugging the code other wise this is not useful we can disable this by typing SET NOCOUNT ON. It is very helpful when we are doing on store procedure contains lots of statements, loops its also increase in performance and boost network traffic.
What are the differences between SQL and PL/SQL?
We can get modify, Retrieve by single command or statement in SQL but PL/SQL process all SQL statements one at a time. With PL/SQL, an entire block of statement process in a single command line. SQL is structured query language, various queries are used to handle the database in a simplified manner. While PL/SQL is procedural language contains various types of variables, functions and procedures and other major diffrence is Sql as the name suggest it is just structured query language wheareas PLSQL is a combination of Programming language & SQL.
What is a join? List different types of joins
Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.
Types of joins:
-INNER JOIN
-OUTER JOIN (OUTER JOIN is further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS)
-CROSS JOINs
What is a Cursor?
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time. For example, you can use cursor to include a list of all user databases and make multiple operations against each database by passing each database name as a variable.
Difference between stored procedure and user defined function
1>Procedure can return zero or n values whereas function can return one value which is mandatory.
2>Procedures can have input, output parameters for it whereas functions can have only input parameters.
3>Procedure allow select as well as DML statement in it whereas function allow only select statement in it.
4>Functions can be called from procedure whereas procedures cannot be called from function.
5>Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
6>We can go for transaction management in procedure whereas we can''t go in function.
7>Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.
|
Posted By: Anonymous
|
Posted Dt: 06-Mar-2012
|
188 25
|
Total Points: 8696
|
RE: sql server interview questions and answers for experienced
Below are few interview questions:
What is Extent and Page?
Extent is a basic unit of storage to provide space for tables. Every extent has number of data pages. As new records are inserted new data pages are allocated. There are eight data pages in an extent. So as soon as the eight pages are consumed it allocates new extent with data pages.
While extent is basic unit storage from database point of view, page is a unit of allocation within extent.
What are the types of JOIN used in SQL Server?
-Inner join
- Outer Join (Left outer join and right outer join)
- Self Join
- Cross Join
What’s the difference between “UNION” and “UNION ALL” ?
UNION SQL syntax is used to select information from two tables. But it selects only distinct records from both the table, while UNION ALL selects all records from both the tables.
What is a cursor?
It is used to handle a set of data. Using cursors, you can loop through all the rows and update data accordingly.
What are the steps involved in creating a cursor?
1. Declare Cursor
2. Open Cursor
3. Fetch the data''s
4. Operation
5. Close and Deallocate
How is the SUBSTR keyword used in SQL?
SUBSTR is used for string manipulation with column name, first position and string length used as arguments.
What is a trigger? Write its syntax.
A Trigger is also a special kind of Stored Procedure which will fire automatically on the happening of an event like before or after insert, update or delete. We cannot call a trigger explicitly from a Stored Procedure.
[SQL]
What is Extent and Page?
Extent is a basic unit of storage to provide space for tables. Every extent has number of data pages. As new records are inserted new data pages are allocated. There are eight data pages in an extent. So as soon as the eight pages are consumed it allocates new extent with data pages.
While extent is basic unit storage from database point of view, page is a unit of allocation within extent.
What are the types of JOIN used in SQL Server?
-Inner join
- Outer Join (Left outer join and right outer join)
- Self Join
- Cross Join
What’s the difference between “UNION” and “UNION ALL” ?
UNION SQL syntax is used to select information from two tables. But it selects only distinct records from both the table, while UNION ALL selects all records from both the tables.
What is a cursor?
It is used to handle a set of data. Using cursors, you can loop through all the rows and update data accordingly.
What are the steps involved in creating a cursor?
1. Declare Cursor
2. Open Cursor
3. Fetch the data''s
4. Operation
5. Close and Deallocate
How is the SUBSTR keyword used in SQL?
SUBSTR is used for string manipulation with column name, first position and string length used as arguments.
What is a trigger? Write its syntax.
A Trigger is also a special kind of Stored Procedure which will fire automatically on the happening of an event like before or after insert, update or delete. We cannot call a trigger explicitly from a Stored Procedure.
[SQL]
CREATE
TRIGGER TriggerName
ON TableName
AFTER INSERT | UPDATE | DELETE
AS
Query to be executed...
GO
ON TableName
AFTER INSERT | UPDATE | DELETE
AS
Query to be executed...
GO
|
Posted By: Anonymous
|
Posted Dt: 18-Mar-2012
|
90 1
|
Total Points: 8696
|
RE: sql server interview questions and answers for experienced
Hi All,
I have given the interview for RBS, Chennai a week ago. They asked me a question in sql server. How to fetch the second highest salary from a table without using top, rowcount and rank keywords...
Could anyone know how to write the query fro fetching the second highest salary without using top, rowcount and rank keywords?
Thanks,
I have given the interview for RBS, Chennai a week ago. They asked me a question in sql server. How to fetch the second highest salary from a table without using top, rowcount and rank keywords...
Could anyone know how to write the query fro fetching the second highest salary without using top, rowcount and rank keywords?
Thanks,
|
Posted By: Anonymous
|
Posted Dt: 18-Mar-2012
|
158 27
|
Total Points: 20889
|
RE: sql server interview questions and answers for experienced
Hi Karthik,
Below are few sql server interview questions and answers.
What are CODD rules?
There are 12 rules that every DBMS should adhere in order to be true RDBMS. These rules were laid by E.F.CODD in 1969.
1. Information Rule
2. Guaranteed access rule
3. Systematic treatment of null values
4. Dynamic on-line catalog based on the relational model
5. Comprehensive data sub-language Rule
6. View updating Rule
7. High-level insert, update and delete
8. Physical data independence
9. Logical data independence
10.Integrity independence
11.Distribution independence
12.Non-subversion Rule
How many types of relationship exists in Database designing?
1. One to One
2. One to Many
3. Many to Many
What is a DDL, DML and DCL concept?
DDL (Data definition language) defines your database structure. CREATE and ALTER are DDL statements as they affect the way your database structure is organized.
DML (Data Manipulation Language) lets you do basic functionalities like INSERT, UPDATE, DELETE and MODIFY data in database.
DCL (Data Control Language) controls you DML and DDL statements so that your data is protected and has consistency. COMITT and ROLLBACK are DCL control statements. DCL guarantees ACID fundamentals of a transaction.
Difference between DELETE and TRUNCATE.
- DELETE table can be rolled back while TRUNCATE can not be.
- DELETE TABLE syntax logs the deletes thus making the delete operations low. TRUNCATE table does not log any information but it logs information about deallocation of data page of the table. So TRUNCATE table is faster as compared to delete table.
- DELETE table can have criteria while TRUNCATE can not.
- TRUNCATE table can not have triggers.
What is a Cursor?
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time.
Thanks,
Priya
Below are few sql server interview questions and answers.
What are CODD rules?
There are 12 rules that every DBMS should adhere in order to be true RDBMS. These rules were laid by E.F.CODD in 1969.
1. Information Rule
2. Guaranteed access rule
3. Systematic treatment of null values
4. Dynamic on-line catalog based on the relational model
5. Comprehensive data sub-language Rule
6. View updating Rule
7. High-level insert, update and delete
8. Physical data independence
9. Logical data independence
10.Integrity independence
11.Distribution independence
12.Non-subversion Rule
How many types of relationship exists in Database designing?
1. One to One
2. One to Many
3. Many to Many
What is a DDL, DML and DCL concept?
DDL (Data definition language) defines your database structure. CREATE and ALTER are DDL statements as they affect the way your database structure is organized.
DML (Data Manipulation Language) lets you do basic functionalities like INSERT, UPDATE, DELETE and MODIFY data in database.
DCL (Data Control Language) controls you DML and DDL statements so that your data is protected and has consistency. COMITT and ROLLBACK are DCL control statements. DCL guarantees ACID fundamentals of a transaction.
Difference between DELETE and TRUNCATE.
- DELETE table can be rolled back while TRUNCATE can not be.
- DELETE TABLE syntax logs the deletes thus making the delete operations low. TRUNCATE table does not log any information but it logs information about deallocation of data page of the table. So TRUNCATE table is faster as compared to delete table.
- DELETE table can have criteria while TRUNCATE can not.
- TRUNCATE table can not have triggers.
What is a Cursor?
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time.
Thanks,
Priya
|
Posted By: Anonymous
|
Posted Dt: 24-Mar-2012
|
50 11
|
Total Points: 5781
|
RE: sql server interview questions and answers for experienced
Hi Vaishnavi,
I have written a query to fetch the second highest salary from the table. Please find the query below and let me know if it is not working
[SQL]
I have written a query to fetch the second highest salary from the table. Please find the query below and let me know if it is not working
[SQL]
select
points from tablename as tbl where (select count(*) from tablename where
salary>=tbl.salary)=2
Thanks,
Hariharan T G
|
Posted By: Anonymous
|
Posted Dt: 27-Mar-2012
|
44 8
|
Total Points: 8696
|
RE: sql server interview questions and answers for experienced
Hi Hari,
Thanks for posting the query. It works fine. :-)
Thanks
Thanks for posting the query. It works fine. :-)
Thanks
|
Posted By: Anonymous
|
Posted Dt: 28-Mar-2012
|
12 3
|
Total Points: 20889
|
RE: sql server interview questions and answers for experienced
Hi All,
Below are the few sql server interview questions.
Difference between truncate and delete in sql server.
• DELETE TABLE syntax logs the deletes thus make the delete operation slow. TRUNCATE table does not log any information but it logs information about deallocation of data page of the table so TRUNCATE table is faster as compared to delete table.
• DELETE table can have criteria while TRUNCATE cannot.
• TRUNCATE table does not invoke trigger.
• TRUNCATE will reset any identity columns to the default seed value.
• You cannot TRUNCATE a table that has any foreign key constraints. You will have to remove the constraints, TRUNCATE the table, and re-apply the constraints.
Difference between where and having clause
• SQL WHERE clause condition is tested against each and every row of data, while the SQL HAVING clause condition is tested against the groups and/or aggregates specified in the SQL GROUP BY clause and/or the SQL SELECT column list.
• HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.
• A HAVING clause is like a WHERE clause, but applies only to groups as a whole, whereas the WHERE clause applies to individual rows. A query can contain both a WHERE clause and a HAVING clause. The WHERE clause is applied first to the individual rows in the tables . Only the rows that meet the conditions in the WHERE clause are grouped. The HAVING clause is then applied to the rows in the result set. Only the groups that meet the HAVING conditions appear in the query output. You can apply a HAVING clause only to columns that also appear in the GROUP BY clause or in an aggregate function.
Difference between DBMS and RDBMS
A DBMS has to be persistent, that is it should be accessible when the program created the data ceases to exist or even the application that created the data restarted. A DBMS also has to provide some uniform methods independent of a specific application for accessing the information that is stored. RDBMS is a Relational Data Base Management System Relational DBMS. This adds the additional condition that the system supports a tabular structure for the data, with enforced relationships between the tables. This excludes the databases that don''t support a tabular structure or don''t enforce relationships between tables. Many DBA''s think that RDBMS is a Client Server Database system but thats not the case with RDBMS.
Thanks,
Balaji T G
Below are the few sql server interview questions.
Difference between truncate and delete in sql server.
• DELETE TABLE syntax logs the deletes thus make the delete operation slow. TRUNCATE table does not log any information but it logs information about deallocation of data page of the table so TRUNCATE table is faster as compared to delete table.
• DELETE table can have criteria while TRUNCATE cannot.
• TRUNCATE table does not invoke trigger.
• TRUNCATE will reset any identity columns to the default seed value.
• You cannot TRUNCATE a table that has any foreign key constraints. You will have to remove the constraints, TRUNCATE the table, and re-apply the constraints.
Difference between where and having clause
• SQL WHERE clause condition is tested against each and every row of data, while the SQL HAVING clause condition is tested against the groups and/or aggregates specified in the SQL GROUP BY clause and/or the SQL SELECT column list.
• HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.
• A HAVING clause is like a WHERE clause, but applies only to groups as a whole, whereas the WHERE clause applies to individual rows. A query can contain both a WHERE clause and a HAVING clause. The WHERE clause is applied first to the individual rows in the tables . Only the rows that meet the conditions in the WHERE clause are grouped. The HAVING clause is then applied to the rows in the result set. Only the groups that meet the HAVING conditions appear in the query output. You can apply a HAVING clause only to columns that also appear in the GROUP BY clause or in an aggregate function.
Difference between DBMS and RDBMS
A DBMS has to be persistent, that is it should be accessible when the program created the data ceases to exist or even the application that created the data restarted. A DBMS also has to provide some uniform methods independent of a specific application for accessing the information that is stored. RDBMS is a Relational Data Base Management System Relational DBMS. This adds the additional condition that the system supports a tabular structure for the data, with enforced relationships between the tables. This excludes the databases that don''t support a tabular structure or don''t enforce relationships between tables. Many DBA''s think that RDBMS is a Client Server Database system but thats not the case with RDBMS.
Thanks,
Balaji T G
|
Posted By: tgbalaji
|
Posted Dt: 28-Mar-2012
|
40 2
|
Total Points: 9450
|
RE: sql server interview questions and answers for experienced
What is a index in sql server?
An index is a physical structure containing pointers to the data. Indexes are created in an existing table to locate rows more quickly and efficiently.
It is possible to create an index on one or more columns of a table, and each index is given a name.
They are just used to speed up queries.
Drawbacks of Index:
- Any DML operation performed in the table will be slow since it has to update the index pointers.
Difference between subquery and corelated subquery?
In a subquery first the the inner query will be executed then the outer query will be executed.
In corelated subquery the inner query refers to the outer query.
What are Clustered & non Clustered Indexes
In clustered index table are physically stored. Only one clustered index. The leaf nodes of a clustered index contain the data pages.
A non clustered index logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows
What are the types of joins in SQL Server?
INNER JOIN
LEFT OUTER JOIN
RIGHT OUTER JOIN
FULL OUTER JOIN
CROSS JOIN
Difference between delete and truncate in sql server.
The deletion of each row gets logged in the transaction log, which makes it slow deletes all the rows in a table, but it won’t log the deletion of each row, instead it logs the deallocation of the data pages of the table, which makes it faster.
Thanks,
An index is a physical structure containing pointers to the data. Indexes are created in an existing table to locate rows more quickly and efficiently.
It is possible to create an index on one or more columns of a table, and each index is given a name.
They are just used to speed up queries.
Drawbacks of Index:
- Any DML operation performed in the table will be slow since it has to update the index pointers.
Difference between subquery and corelated subquery?
In a subquery first the the inner query will be executed then the outer query will be executed.
In corelated subquery the inner query refers to the outer query.
What are Clustered & non Clustered Indexes
In clustered index table are physically stored. Only one clustered index. The leaf nodes of a clustered index contain the data pages.
A non clustered index logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows
What are the types of joins in SQL Server?
INNER JOIN
LEFT OUTER JOIN
RIGHT OUTER JOIN
FULL OUTER JOIN
CROSS JOIN
Difference between delete and truncate in sql server.
The deletion of each row gets logged in the transaction log, which makes it slow deletes all the rows in a table, but it won’t log the deletion of each row, instead it logs the deallocation of the data pages of the table, which makes it faster.
Thanks,
|
Posted By: Anonymous
|
Posted Dt: 30-Mar-2012
|
40 1
|
Total Points: 8696
|
RE: sql server interview questions and answers for experienced
Good collection of SQL Interview questions and
answers.
Please post more questions..
Thanks
Please post more questions..
Thanks
|
Posted By: Rocket Raja
|
Posted Dt: 12-May-2012
|
6 8
|
Total Points: 522
|
RE: sql server interview questions and answers for experienced
What are the error functions used in SQL Try catch
block?
TRY…CATCH uses the following error functions to capture error information:
- ERROR_NUMBER() returns the error number.
- ERROR_MESSAGE() returns the complete text of the error message. The text includes the values supplied for any substitutable parameters such as lengths, object names, or times.
- ERROR_SEVERITY() returns the error severity.
- ERROR_STATE() returns the error state number.
- ERROR_LINE() returns the line number inside the routine that caused the error.
- ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred.
What new indexes are introduced in SQL Server 2005 in comparison to 2000?
- Spatial
- XML
What are Cursors and their types? What type do you use most and which one is fast?
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time.
Types: FORWARD-ONLY, FAST-FORWARD or READ-ONLY cursors.
Fastest to slowest: Dynamic, Static, and Keyset.
Difference between DELETE & TRUNCATE statement? Which statement can be Rollbacked?
- With DELETE we can provide conditional WHERE clause to remove/delete specific rows, which is not possible with TRUNCATE.
- TRUNCATE is faster than DELETE as Delete keeps log of each row it deletes in transaction logs, but truncate keeps log of only de-allocated pages in transaction logs.
- Both statements can be rolled backed if provided in a transaction (BEGIN TRANS). If not then none of them can be rollbacked.
- DELETE is DML just like INSERT, UPDATE, but TRANCATE is DDL, just like CREATE, ALTER, DROP
What are the tools that could be used for SQL Query performance tuning?
Query Analyzer, Profiler, Index Wizard, Performance Monitor
Thanks,
TRY…CATCH uses the following error functions to capture error information:
- ERROR_NUMBER() returns the error number.
- ERROR_MESSAGE() returns the complete text of the error message. The text includes the values supplied for any substitutable parameters such as lengths, object names, or times.
- ERROR_SEVERITY() returns the error severity.
- ERROR_STATE() returns the error state number.
- ERROR_LINE() returns the line number inside the routine that caused the error.
- ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred.
What new indexes are introduced in SQL Server 2005 in comparison to 2000?
- Spatial
- XML
What are Cursors and their types? What type do you use most and which one is fast?
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time.
Types: FORWARD-ONLY, FAST-FORWARD or READ-ONLY cursors.
Fastest to slowest: Dynamic, Static, and Keyset.
Difference between DELETE & TRUNCATE statement? Which statement can be Rollbacked?
- With DELETE we can provide conditional WHERE clause to remove/delete specific rows, which is not possible with TRUNCATE.
- TRUNCATE is faster than DELETE as Delete keeps log of each row it deletes in transaction logs, but truncate keeps log of only de-allocated pages in transaction logs.
- Both statements can be rolled backed if provided in a transaction (BEGIN TRANS). If not then none of them can be rollbacked.
- DELETE is DML just like INSERT, UPDATE, but TRANCATE is DDL, just like CREATE, ALTER, DROP
What are the tools that could be used for SQL Query performance tuning?
Query Analyzer, Profiler, Index Wizard, Performance Monitor
Thanks,
SQL Queries Interview
Questions and Answers on "SQL Select" - Examples
1. Get all employee details from the employee table
Select
* from employee
2. Get First_Name,Last_Name from employee table
Select
first_name, Last_Name from employee
3. Get
First_Name from employee table using alias name “Employee Name”
Select
first_name Employee Name from employee
4. Get
First_Name from employee table in upper case
Select
upper(FIRST_NAME) from EMPLOYEE
5. Get
First_Name from employee table in lower case
Select lower(FIRST_NAME) from EMPLOYEE
6. Get
unique DEPARTMENT from employee table
select distinct DEPARTMENT from EMPLOYEE
7. Select
first 3 characters of FIRST_NAME from EMPLOYEE
Oracle Equivalent of
SQL Server SUBSTRING is SUBSTR, Query : select substr(FIRST_NAME,0,3) from employee
SQL Server Equivalent
of Oracle SUBSTR is SUBSTRING,
Query : select substring(FIRST_NAME,0,3) from employee
MySQL Server
Equivalent of Oracle SUBSTR is SUBSTRING. In MySQL start position is 1, Query : select substring(FIRST_NAME,1,3)
from employee
8. Get
position of 'o' in name 'John' from employee table
Oracle Equivalent of
SQL Server CHARINDEX is INSTR,
Query : Select instr(FIRST_NAME,'o') from employee where first_name = 'John'
SQL Server Equivalent
of Oracle INSTR is CHARINDEX,
Query: Select CHARINDEX('o',FIRST_NAME,0) from employee where first_name =
'John'
MySQL Server
Equivalent of Oracle INSTR is LOCATE, Query: Select LOCATE('o',FIRST_NAME) from employee where
first_name = 'John'
9. Get
FIRST_NAME from employee table after removing white spaces from right side
select RTRIM(FIRST_NAME) from employee
10. Get
FIRST_NAME from employee table after removing white spaces from left side
select LTRIM(FIRST_NAME) from employee
11. Get
length of FIRST_NAME from employee table
Oracle,MYSQL
Equivalent of SQL Server Len is Length , Query :select length(FIRST_NAME) from employee
SQL Server Equivalent
of Oracle,MYSQL Length is Len,
Query :select len(FIRST_NAME) from employee
12. Get
First_Name from employee table after replacing 'o' with '$'
select REPLACE(FIRST_NAME,'o','$') from
employee
13. Get
First_Name and Last_Name as single column from employee table separated by a
'_'
Oracle Equivalent of
MySQL concat is '||',
Query : Select FIRST_NAME|| '_' ||LAST_NAME from EMPLOYEE
SQL Server Equivalent
of MySQL concat is '+',
Query : Select FIRST_NAME + '_' +LAST_NAME from EMPLOYEE
MySQL Equivalent of
Oracle '||' is concat,
Query : Select concat(FIRST_NAME,'_',LAST_NAME) from EMPLOYEE
14. Get
FIRST_NAME ,Joining year,Joining Month and Joining Date from employee table
SQL Queries in Oracle, Select FIRST_NAME,
to_char(joining_date,'YYYY') JoinYear , to_char(joining_date,'Mon'),
to_char(joining_date,'dd') from EMPLOYEE
SQL Queries in SQL
Server, select SUBSTRING (convert(varchar,joining_date,103),7,4)
, SUBSTRING (convert(varchar,joining_date,100),1,3) , SUBSTRING
(convert(varchar,joining_date,100),5,2) from EMPLOYEE
SQL Queries in MySQL, select
year(joining_date),month(joining_date), DAY(joining_date) from EMPLOYEE
SQL
Server 2008 Interview Questions and Answers.
What is RDBMS?
Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.
Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.
What is normalization?
Database normalization is a data design and organization process applied to data structures based on rules that help build relational databases. In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.
What are different normalization forms?
Database normalization is a data design and organization process applied to data structures based on rules that help build relational databases. In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.
What are different normalization forms?
1NF: Eliminate Repeating Groups
Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table.All attributes must be directly dependent on the primary key
BCNF: Boyce-Codd Normal Form
If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.
4NF: Isolate Independent Multiple Relationships
No table may contain two or more 1:n or n:m relationships that are not directly related.
5NF: Isolate Semantically Related Multiple Relationships
There may be practical constrains on information that justify separating logically related many-to-many relationships.
ONF: Optimal Normal Form
A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.
DKNF: Domain-Key Normal Form
A model free from all modification anomalies.
Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table.All attributes must be directly dependent on the primary key
BCNF: Boyce-Codd Normal Form
If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.
4NF: Isolate Independent Multiple Relationships
No table may contain two or more 1:n or n:m relationships that are not directly related.
5NF: Isolate Semantically Related Multiple Relationships
There may be practical constrains on information that justify separating logically related many-to-many relationships.
ONF: Optimal Normal Form
A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.
DKNF: Domain-Key Normal Form
A model free from all modification anomalies.
Remember, these normalization guidelines are cumulative. For a
database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF
database.
What is Stored Procedure?
A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database.
e.g. sp_helpdb, sp_renamedb, sp_depends etc.
A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database.
e.g. sp_helpdb, sp_renamedb, sp_depends etc.
What is Trigger?
A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the DBMS.Triggers are used to maintain the referential integrity of data by changing the data in a systematic fashion. A trigger cannot be called or executed; the DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers can be viewed as similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.
Nested Trigger: A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.
A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the DBMS.Triggers are used to maintain the referential integrity of data by changing the data in a systematic fashion. A trigger cannot be called or executed; the DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers can be viewed as similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.
Nested Trigger: A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.
What is View?
A simple view can be thought of as a subset of a table. It can be used for retrieving data, as well as updating or deleting rows. Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table. The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.
A simple view can be thought of as a subset of a table. It can be used for retrieving data, as well as updating or deleting rows. Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table. The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.
What is Index?
An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes, they are just used to speed up queries. Effective indexes are one of the best ways to improve performance in a database application. A table scan happens when there is no index available to help a query. In a table scan SQL Server examines every row in the table to satisfy the query results. Table scans are sometimes unavoidable, but on large tables, scans have a terrific impact on performance.
An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes, they are just used to speed up queries. Effective indexes are one of the best ways to improve performance in a database application. A table scan happens when there is no index available to help a query. In a table scan SQL Server examines every row in the table to satisfy the query results. Table scans are sometimes unavoidable, but on large tables, scans have a terrific impact on performance.
Clustered indexes define the physical sorting of a
database table’s rows in the storage media. For this reason, each database
table may have only one clustered index.
Non-clustered indexes are created outside of the database table and contain a sorted list of references to the table itself.
Non-clustered indexes are created outside of the database table and contain a sorted list of references to the table itself.
Sql
Server interview - July 10, 2011 by Swati Parakh
Difference
between drill down and drill through report.
Both the drill down and drill
through report provide interactive functionality to the SSRS report. The
differences are as follows:-
What’s
the use of custom fields in report?
Custom fields can be defined
as alias column of the report since the operation is performed on report
server rather than on database server. The custom field is very useful for
the data manipulation like adding some fields whose value can be calculated
based on expression, text e.g. instead of CName fetched from database, I
want the dataset to display Customer Name etc.
We can add custom fields as
right click on dataset, select add in Dataset window. The New field dialog
box will open, we can add name of custom field and also mention whether it
is database field or calculated one. If it is calculated, then we can
mention the computation in this window.
Can
we use custom code in SSRS? If so, explain how we can do.
Yes, we can. SSRS allows
developer to add custom code in your report. You can write the code
directly into embedded VB.Net and call it using property expression or you
can write a custom class library and refer it in report server. The
advantage of first method is that it is simple and easy to use but
disadvantage is that it is available for that report only. While the second
method has advantage of being available for multiple reports but it has
much of configuration overhead.
To write custom code, right
click on Report Designer outside report body and select Properties and go
to Code tab and you can write custom code here.
To add custom class library,
right click on Report Designer outside report body and select Properties
and go to Reference tab and add the reference by browsing to the assembly
of your class library. Note that you need to create class library and then
compile it before referencing it in your SSRS report.
Sql
Server interview - July 16, 2011 by Swati Parakh
Difference
between report and query parameter. Why do we need different type of
parameter?
How
does your SSRS maintain security?
Reporting services maintain
role based security. When a user logs into reporting services, a Report
Manager (whose duty is to maintain security of Reporting Services) first
checks the identity of user and then determine what rights he have to
perform on report.
Report Manager manages the
security at 2 levels –
1. System-level – Administer the report server globally 2. Item-level – Security at report and dataset level
System-level roles are:-
1. System Administrator – can manage report server and report manager security 2. Site User - view basic information like report properties and schedules.
Item-level roles – User can
use any of predefined item-level roles or create their own roles by using
combination of predefined item-level roles.
Pre-defined Item-level roles are:- 1. Browser – can navigate to report and run them. 2. My Reports – these users’ rights is restricted to reports present in their MyReports folder. However, they can create, view and manage reports in their folder. 3. Publisher – As name suggest, publisher user has rights to publish reports to Reporting Server database. 4. Content Manager – has all permission at item-level.
SQL
Server interview questions and answers - submitted by Arpit Jain
What
is SQL Injection?
String sql = “Select EmpName,
City from EmployeeMaster where EmpName like ‘%” + txtSearch.Text + “%’”;
But the attacker might enter the keyword like ‘ UNION SELECT name, type, id from sysobjects;--
This way attacker can get
details of all the objects of the application database and using that
attacker can steal further information.
What
is DBCC? Give few examples.
For example –
1. DBCC CHECKALLOC – It is
used to check that all pages are correctly allocated in database.
2. DBCC CHECKDB – It is used to check that 3. DBCC SQLPERF – It generates a report for the current usage of 4. DBCC SQLFILEGROUP – It used to check all the tables file group for any design.
What
is difference between View and Materialized view?
What
is CTE (Common Table Expression)?
SELECT * FROM (
SELECT emp.EmpName,dept.Department,emp.Gender FROM Employee emp left join Department dept on emp.DeptID = dept.DeptID) E WHERE E.Gender = ‘Male’ ORDER BY T.EmpName
The syntax of CTE is as
follow
- The CTE Name (followed by WITH keyword) - The Column List (Optional) - The Query (Appears within parentheses after the AS keyword)
If we write the above messy
query using CTE it would be like
With E(EmpName, Department, Gender) AS ( SELECT emp.EmpName,dept.Department,emp.Gender FROM Employee emp left join Department dept on emp.DeptID = dept.DeptID ) SELECT * FROM E WHERE E.Gender = ‘Male’ ORDER BY E.EmpName
This way the query can be
made more readable and easy to understand.
What
is difference between clustered and non clustered index?
What
is use of EXCEPT clause? How it differs from NOT IN clause.
-When we combine two queries
using EXCEPT clause, it will returns distinct rows from the first SELECT
statement that are not returned by the second one.
-EXCEPT clause works the same way as the UNION operator of SQL and MINUS clause in Oracle. -The syntax of EXCEPT clause is as follow SELECT column1 [, column2 ] FROM table1 [, table2 ] [WHERE condition]
EXCEPT
SELECT column1 [, column2 ] FROM table1 [, table2 ] [WHERE condition] -The difference between EXCEPT and NOT IN clause is EXCEPT operator returns all distinct rows from the rows returned by first select statement which does not exist in the rows returned by second select statement. On the other hand “NOT IN” will return all rows from returned by first select statement which does not exist in the rows returned by second select statement.
What
is difference between Index Seek vs. Index Scan?
What
is ROW_NUMBER function?
What
is Trigger?
-In SQL the Trigger is the
procedural code that executed when you INSERT, DELETE or UPDATE data in the
table.
-Triggers are useful when you want to perform any automatic actions such as cascading changes through related tables, enforcing column restrictions, comparing the results of data modifications and maintaining the referential integrity of data across a database. -For example, to prevent the user to delete the any Employee from EmpDetails table, following trigger can be created. create trigger del_emp on EmpDetails for delete as begin rollback transaction print "You cannot delete any Employee!" end -When someone will delete a row from the EmpDetails table, the del_emp trigger cancels the deletion, rolls back the transaction, and prints a message "You cannot delete any Employee!"
What
is Scheduled job and how to create it?
-If we want to execute any
procedural code automatically on specific time either once or repeatedly
then we can create a Scheduled job for that code.
-Following are the steps to create a Scheduled Job. 1. Connect to your database of SQL server in SQL Server Management Studio. 2. On the SQL Server Agent. There you will find a Jobs folder. Right click on jobs and choose Add New. 3. A New Job window will appear. Give a related name for the job. 4. Click next on the "Steps" in the left menu. A SQL job can have multiple steps either in the form of SQL statement or a stored procedure call. 5. Click on the "Schedules" in the left menu. A SQL job can contain one or more schedules. A schedule is basically the time at which sql job will run itself. You can specify recurring schedules also. -Using scheduled job you can also create alert and notifications.
What
is OPENXML in SQL Server?
-OPENXML provides an easy way
to use an XML document as a data-source for your procedures.
-OPENXML data can be manipulated the same way we deal with database tables by treating xml tags in the form of columns and the value in the form of rows. -By using OPENXML Data can be inserted or updated very quickly without multiple trips to the database. -Example: DECLARE @count int DECLARE @xml varchar(5000) SET @xml ='<Employees> <Employee id="1"> <Name>Arpit</Name> <Employee >1234</ Employee > </Employee > <Employee id="2"> <Name>Rahul</Name> <PhoneNo>2211</PhoneNo> </Employee > </Employees>' EXEC sp_xml_preparedocument @count OUTPUT, @xml SELECT * FROM OPENXML (@count, Employees/Employee') WITH (id Varchar(10), Name varchar(100) 'Name' , PhoneNo Varchar(50) 'PhoneNo') EXEC sp_xml_removedocument @index It will give following result. 1 Arpit 1234 2 Rahul 2211
What
are Sparse columns?
What
is RANK function?
-RANK is one of the Ranking
functions which are used to give rank to each row in the result set of a
SELECT statement.
-For using this function
first specify the function name, followed by the empty parentheses.
-Then specify the OVER
function. For this function, you have to pass an ORDER BY clause as an
argument. The clause specifies the column(s) that you are going to rank.
For Example
SELECT RANK() OVER(ORDER BY Salary DESC) AS [RowNumber], EmpName, Salary, [Month], [Year] FROM EmpSalary
-In the result you will see
that the highest salary got the first rand and the lowest salary got the
last rank.
Here the rows with equal salaries will get same ranks. -Remember that the rank depends on the row's position in the result set, not on the sequential number of the row.
What
are cursors and when they are useful?
-When we execute any SQL
operations, SQL Server opens a work area in memory which is called Cursor.
-When it is required to perform the row by row operations which are not possible with the set-based operations then Cursor is used. -There are two of cursors
1. Implicate Cursor
SQL Server automatically manages cursors for all data manipulation statements. These cursors are called implicit cursors. 2. Explicit Cursor When the programmer wants to perform the row by row operations for the result set containing more than one row, then he explicitly declare a cursor with a name. They are managed by OPEN, FETCH and CLOSE.
%FOUND, %NOFOUND, %ROWCOUNT
and %ISOPEN attributes are used in both types of cursors.
What
is log shipping?
-SQL has introduced Log
Shipping feature to synchronize the Distributed Database Server.
Synchronize the database by copying Transaction logs, Backing up, Restoring
data. SQL Server Job Agents is used to make these processes automatic.
-In the case of failure the Log Shipping will not transfer the server. That means it will not redirect your application to other server. This has to be done manually. -Log shipping synchronizes the database only. The main functions of Log Shipping are as follows: 1. To Back up the transaction log of the primary database 2. To Copy the transaction log backup to every secondary server 3. To Restore the transaction log backup on the secondary database
What
is SQL Profiler?
-SQL Server provides a
graphical tool which helps system administrators to monitor T-SQL
statements of Database Engine.
-SQL Profiler can capture and
store data related to every event to a file or a table.
-SQL Server Profiler can be
used
1. To create a trace
2. To store the trace results in a table. 3. To watch the trace results when the trace runs 4. To replay the trace results 5. To start, stop, pause, and modify the trace results
What
is Similarity and Difference between Truncate and Delete in SQL?
Similarity
-These both command will only
delete data of the specified table, they cannot remove the whole table data
structure.
Difference
-TRUNCATE is a DDL (data
definition language) command whereas DELETE is a DML (data manipulation
language) command.
-We can’t execute a trigger in case of TRUNCATE whereas with DELETE command, we can execute a trigger. -TRUNCATE is faster than DELETE, because when you use DELETE to delete the data, at that time it store the whole data in rollback space from where you can get the data back after deletion. In case of TRUNCATE, it will not store data in rollback space and will directly delete it. You can’t get the deleted data back when you use TRUNCATE. -We can use any condition in WHERE clause using DELETE but you can't do it with TRUNCATE. -If table is referenced by any foreign key constraints then TRUNCATE will not work.
What
is Normalization of database? What are its benefits?
-Normalization is set of
rules that are to be applied while designing the database tables which are
to be connected with each other by relationships. This set of rules is called
Normalization.
-Benefits of normalizing the
database are
1. No need to restructure existing tables for new data. 2. Reducing repetitive entries. 3. Reducing required storage space 4. Increased speed and flexibility of queries.
What
is Fill factor?
What
are different types of replication in SQL Server?
There are three types of
replication in SQL SERVER
1. Snapshot Replication.
2. Transactional Replication
3. Merge Replication
What
is REPLACE and STUFF function in SQL Server?
STUFF: This function is used
to replace the part of string with some another string.
Syntax:
STUFF (String1, Position,
Length, String2)
String1 - String to be overwritten Position - Starting Position for overwriting Length - Length of replacement string String2- String to overwrite
Example:
SELECT STUFF(‘Arpit',2,2,'mi') Output: Amit
REPLACE: This function is
used to replace all the occurrences of particular string by another string.
Syntax:
REPLACE(String1, String2, String3)
Example:
SELECT REPLACE(‘Arpit Jain’,’i’,’m’) Output: Arpmt Jamn
If you want to replace the
first occurrence of “I”, Replace wouldn't work, because it always replaces
ALL occurrences of the string.
Give
a example to search for a string in all stored procedure in SQL Server.
-Suppose we have a EmpDetails
table in our database and there are certain number of stored procedures in
database. We want to know in which stored procedure(s) table EmpDetails is
used.
-We can use following query
SELECT
sys.objects.name, sys.objects.type, sys.objects.type_desc, sys.objects.schema_id, sys.syscomments.text FROM sys.objects INNER JOIN sys.syscomments ON sys.objects.object_id = sys.syscomments.id where sys.syscomments.text like '%EmpDetails%' And type ='P'
What
are Magic tables in SQL Server?
-In SQL Server there are two
system tables “Inserted” and “Deleted” called Magic tables.
-These are not the physical
tables but the virtual tables generally used with the triggers to retrieve
the inserted, deleted or updated rows.
-When a record is inserted in
the table that record will be there on INSERTED Magic table.
-When a record is updated in
the table that existing record will be there on DELETED Magic table and
modified data will be there in INSERTED Magic table.
-When a record is deleted from
that table that record will be there on DELETED Magic table.
What
is difference between stored procedure and user defined function?
What
are ACID properties of Transaction?
Following are the ACID
properties for Database.
Atomicity – Transactions may
be set of SQL statements. If any of statement fails then the entire
transaction fails. The transaction follows all or nothing rule.
Consistency – This property
says that the transaction should be always in consistent state. If any
transaction is going to effect the database’s consistent state then the
transaction could be rolled back.
Isolation – This property
says that one transaction can not retrive the data that has been modified
by any other transaction until its completed.
Durability – When any
transaction is committed then it must be persisted. In the case of failure
only committed transaction will be recovered and uncommitted transaction
will be rolled back.
What
are COMMIT and ROLLBACK in SQL?
COMMIT statement is used to
end the current transaction and once the COMMIT statement is exceucted the
transaction will be permanent and undone.
Syntax: COMMIT;
Example:
BEGIN UPDATE EmpDetails SET EmpName = ‘Arpit’ where Dept = ‘Developer’ COMMIT; END; ROLLBACK statement is used to end the current transaction and undone the changes which was made by that transaction.
Syntax: ROLLBACK [TO] Savepoint_name;
Example
BEGIN Statement1; SAVEPOINT mysavepoint; BEGIN Statement2; EXCEPTION WHEN OTHERS THEN ROLLBACK TO mysavepoint; Statement5; END; END;
What
is a Linked Server?
What
is a WITH(NOLOCK)?
What
are the basic functions for master, msdb, model, tempdb databases?
List
few advantages of Stored procedure.
Test your sql
server knowledge with our multiple choice questions!
Next>> Part 1 | Part 2 | Part 3 | Part 4 | part 5 | part 6 | part 7 | part 8 | part 9
Also read
|
|
No comments:
Post a Comment