Professional Documents
Culture Documents
com/c-interview-question-part-2/
http://learnsqltips.blogspot.in/2012/01/introduction-to-sql-server.html
http://www.smarttestguru.com/online-test-interview-questions.aspx?id=12
http://arindamcctvaccesscontrol.blogspot.in/2014/03/difference-between-sql-server20002005.html
http://touchstone-systems.co.uk/blog/?p=74
http://www.sqlserverquest.com/p/tsql-interview-questions.html
http://www.gcreddy.com/2014/06/sql-queries.html
Database
What
What
What
What
What
is DBMS?
is RDBMS?
are the ACID properties?
is Normalization?
is D-normalization and when do we need it?
Table Design
What is Table? *
What is Data type? *
What are the different types of data types in SQL Server? *
What is the difference between Float, BIG Int and Integer? *
Explain the Decimal Data types and its uses. *
What is the use of different types of Integer data types? *
What is the difference between bit, Char and Varchar? *
What is Unicode? **
What is the difference between Varchar and Nvarchar? **
What are different date time data types? *
What are unique identifiers in SQL Server Table? **
What is check constraint in SQL Server? **
What is default constraint? *
What is Null ability? *
Explain table relationship? *
What is Primary Key? *
What is Foreign Key? *
What is composite key? *
What are Primary Key and Foreign Key Constraint? *
How to get the list of primary key and foreign key of the table? ****
Can we insert null value in primary column? *
No we cant insert null value in a single column primary key while in composite
primary key only one column can be null
What is difference between Primary Key and Unique Key? **
We can insert one null value in unique key but not in primary key.
What is Identity Column in Table? *
Syntax to check current Identity of the table? *
What is the difference between Scope of Identity on @@identity? ***
Can we change identity key values for a table or reset the identity key value. ***
What is function Ident_INCR? ***
What is times stamp data type is SQL Server? **
What is the alternative of timestamp? **
VIEWS
What is the view in SQL Server? **
What are the updated views? ***
What are the materialized views or Indexed Views in SQL Server? ****
What is view with check option? ****
The with check option causes the where clause of the view to check the data being
inserted or updated through the view in addition to the data being retrieved. In a
sense, it makes the where clause a two-way restriction.
This option is useful when the view should limit inserts and updates with the same
restrictions applied to the where clause.
Write the Create syntax for Views. **
Stored procedure
What is stored procedure in SQL Server? **
How to pass record set in stored procedure? ***
Is nesting possible in stored procedure? If yes How many number of times? ***
Write the create syntax for the procedure. **
How to return output parameter from stored procedure? ***
How to perform error handling in Stored procedure? ****
Function
What is the User defined functions? **
What are the difference types of UDF? **
What are difference between UDF and stored procedure? ***
Can we create a table in function? ****
Triggers
What is a trigger in SQL Server? **
What is the nesting level of triggers? **
What are the different types of triggers in SQL Server? ***
Cursors
What is the cursor in SQL server? **
What are the different types of cursor in SQL Server? ***
When to use Cursor in SQL Server? ***
Index
What is Index in SQL Server? ***
Explain different types of index in SQL Server? ***
What is filter index in SQL Server? ****
What is Covering Index? ****
What is index scan and index seek? ****
What is B+ tree index? ****
Explain the architecture of the index? ****
Explain the performance impact of index? ****
Can we create clustered index on null value column? ****
What are indexes in SQL Server? ****
How many clustered index can be created on the table? ****
How to enforce index on a query? ****
Performance tuning
What is SQL Profiler?
SQL Profiler is a tool that captures SQL Server events from the server and saves those events in
what's
known as a trace file. You can then analyze or use the trace file to troubleshoot logic or performance
problems. You can use this utility to monitor several areas of server activity, such as:
Stress analysis.
Fine-tuning indexes.
Transaction
What are the different types of transaction errors?
What is No lock?
What happens if a transaction is failed in nested transaction, then other outer
transactions will execute or not?
What is isolation level in SQL Server?
What are different types of isolation level in SQL Server?
What is default isolation Level for SQL Server?
RANDOM
Write a query to find the nth minimum and maximum.
Write a query to get the last record of the table.
Write a query to get the no rows of a table without using count or any other
clause.
How many columns can be used with roll up or with cube command?
10 columns
How many columns can be selected in a select statement?
4096 columns can be selected.
How many columns can be selected in an insert statement?
4096 columns can be selected.
What level of nesting is possible for sub Queries?
32 level of nesting.
What level of nesting is possible for Triggers?
32 level of nesting.
How many non-clustered indexes can be created on a table?
Only one clustered index can be created
How many parameters can be provided to a stored procedure?
2100 parameters can be provided to a SP.
How many parameters can be provided to a UDF?
2100 parameters can be provided to a UDF.
How many columns can be taken in update statement?
4096 columns can be updated in an update statement
What is NO COUNT used for?
What is SET ANSI NULL ON used for?
What is arithmetic abort used for?
What is SET ROW COUNT used for?
What is SET ANSI padding?
What is SET ANSI WARNING on?
What is SET NO EXEC?
Which command using Query Analyzer will give you the version of SQL server and
operating system?
How to delete duplicate records from table using query?
As we all know the basic difference between varchar and Nvarchar is that one holds
non Unicode and other holds Unicode data. But we are just aware theoretically and
dont know how it works actually.
Here I am showing an example of how varchar and nvarchar data types works in
query analyzer
Declare @sampleVar varchar(10)
Declare @sampleNVar nvarchar(10)
set @sampleVar = 'VarSamp '
set @sampleNVar = 'NVarSamp '
Select @sampleNVar, @sampleVar
set @sampleNVar = N'NVarSamp '
set @sampleVar = N'VarSamp '
Select @sampleNVar, @sampleVar
If you will see we have added the suffix N while setting the Unicode data type and
its displays the results otherwise it shows the same result as varchar data type. By
seeing this example we can say in Unicode data types can be handled through
nvarchar so while developing bilingual application or if there is any possibility to use
current application in different languages we should use Nvarchar data types.
Keywords: How to read nvarchar data in SQL Query Analyzer, SQL Server Data
types, SQL Server Questions, Varchar ,Nvarchar.
Datetime
Stores dates from January 1, 1753 through December 31, 9999, to an accuracy of one threehundredth of a second (equivalent to 3.33 milliseconds or 0.00333 seconds). Values are rounded to
increments of .000, .003, or .007 seconds, as shown in the table.
Small Datetime
Stores dates from January 1, 1900, through June 6, 2079, with accuracy to the minute. smalldatetime
values with 29.998 seconds or lower are rounded down to the nearest minute; values with 29.999
seconds or higher are rounded up to the nearest minute.
Internally SQL server stores Datetime data in 2 4 bytes integers and smalldatetime stores as 2 2 byte
integers. One part stores days before or after base date and next part stores the number of
milliseconds after midnight.
How to Get the Primary Key and foreign Key between two
tables
These are the few tables which can be used to check the foreign key and
primary key column in a table.
It will give both columns from both tables.
INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
INFORMATION_SCHEMA.TABLE_CONSTRAINTS
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
These properties can be set in for table while designing it or opening existing table in design mode.
Consecutive values within a transaction If there are multiple transaction then the identity value
for every row can be differ in a single transaction.
Reuse of values if there is error while inserting row that the identity generated will lost and next
time SQL server will insert new identity value. It doesn't reuse it.
The seed value is the value inserted into an identity column for the very first row loaded into the table.
@@IDENTITY returns the last identity values that are generated in any table in the current session. Its
not limited to any specific scope. I.e. while updating in current scope the trigger on this table insert data in
some other table
For example, there are two tables, Table1 and Table2, and an INSERT trigger is defined on Table1.
When a row is inserted to Table1, the trigger inserts a row in Table2. This scenario illustrates two scopes:
the insert on Table1 and the insert on Table2 by the trigger.
Table1 and Table2 have identity columns, @@IDENTITY and SCOPE_IDENTITY will return different
values at the end of an INSERT statement on Table1.
@@IDENTITY will return the last identity column value inserted across any scope in the current session.
This is the value inserted in Table2.
SCOPE_IDENTITY () will return the IDENTITY value inserted in Table1.
Sql Server
10 Complex Sql Query on basis of Sql
Interview Question between 1 to 5 year
work experience.
1. Sql Query to find second highest salary of Employee.
select MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary)
from Employee );
GROUP BY DeptID.
3.Write a SQL Query to print the name of distinct employee whose DOB
is between 01/01/1960 to 31/12/1975.
SELECT DISTINCT EmpName FROM
31/12/1975;
[adsenseyu1]
WHERE
Employees WHERE
Salary>=10000;
6. Write an SQL Query to find name of employee whose name Start with
M
SELECT * FROM Employees WHERE EmpName like 'M%';
7. Select all record from emp table where deptno =10 or 40.
select * from emp where deptno=30 or deptno=10;
9.How can I retrive all records of emp1 those should not present in
emp2?
Select * from emp) Minus (Select * from emp1
10.How to fetch only common records from two tables emp and emp1?
(Select * from emp) Intersect (Select * from emp1)