0% found this document useful (0 votes)
138 views21 pages

C# Exception Handling and Debugging Guide

This summary provides an overview of key points about .NET fundamentals from the document: 1. The document discusses various .NET concepts like StringBuilder being more efficient than String for text manipulation, sorting arrays in descending order using Sort() and Reverse(), and the HashTable datatype allowing retrieval by key. 2. It also covers .NET fundamentals like finally blocks executing regardless of exceptions, catch blocks only one firing per exception, and delegates encapsulating method references. 3. The document examines .NET debugging and testing like the This window showing instance data, assert() displaying errors in debug builds, and unit testing covering positive, negative, and exception cases.

Uploaded by

Lal Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views21 pages

C# Exception Handling and Debugging Guide

This summary provides an overview of key points about .NET fundamentals from the document: 1. The document discusses various .NET concepts like StringBuilder being more efficient than String for text manipulation, sorting arrays in descending order using Sort() and Reverse(), and the HashTable datatype allowing retrieval by key. 2. It also covers .NET fundamentals like finally blocks executing regardless of exceptions, catch blocks only one firing per exception, and delegates encapsulating method references. 3. The document examines .NET debugging and testing like the This window showing instance data, assert() displaying errors in debug builds, and unit testing covering positive, negative, and exception cases.

Uploaded by

Lal Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 21

 What’s the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is
more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each
time it’s being operated on, a new instance is created.
 Can you store multiple data types in System.Array? No.
 What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The first
one performs a deep copy of the array, the second one is shallow.
 How can you sort the elements of the array in descending order? By calling Sort() and then
Reverse() methods.
 What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable.
 What’s class SortedList underneath? A sorted HashTable.
 Will finally block get executed if the exception had not occurred? Yes.
 What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible
exception? A catch block that catches the exception of type System.Exception. You can also omit the
parameter data type in this case and just write catch {}.
 Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is
transferred to the finally block (if there are any), and then whatever follows the finally block.
 Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has
occurred, then why not write the proper code to handle that error instead of passing a new Exception object
to the catch block? Throwing your own exceptions signifies some design flaws in the project.
 What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred
to as function pointers.
 What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.
 How’s the DLL Hell problem solved in .NET? Assembly versioning allows the application to specify
not only the library it needs to run (which was available under Win32), but also the version of the
assembly.
 What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command.
 What’s a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and
want to distribute the core application separately from the localized modules, the localized assemblies that
modify the core application are called satellite assemblies.
 What namespaces are necessary to create a localized application? System.Globalization,
System.Resources.
 What’s the difference between // comments, /* */ comments and /// comments? Single-line, multi-
line and XML documentation comments.
 How do you generate documentation from the C# file commented properly with a command-line
compiler? Compile it with a /doc switch.
 What’s the difference between <c> and <code> XML documentation tag? Single line code example
and multiple-line code example.
 Is XML case-sensitive? Yes, so <Student> and <student> are different elements.
 What debugging tools come with the .NET SDK? CorDBG – command-line debugger, and DbgCLR
– graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original
C# file using the /debug switch.
 What does the This window show in the debugger? It points to the object that’s pointed to by this
reference. Object’s instance data is shown.
 What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and
shows the error dialog if the condition is false. The program proceeds without any interruption if the
condition is true.
 What’s the difference between the Debug class and Trace class? Documentation looks the same.
Use Debug class for debug builds, use Trace class for both debug and release builds.
 Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be
quite verbose and for some applications that are constantly running you run the risk of overloading the
machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing
activities.
 Where is the output of TextWriterTraceListener redirected? To the Console or a text file
depending on the parameter passed to the constructor.
 How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr
debugger.
 What are three test cases you should go through in unit testing? Positive test cases (correct data,
correct output), negative test cases (broken or missing data, proper handling), exception test cases
(exceptions are thrown and caught properly).
 Can you change the value of a variable while debugging a C# application? Yes, if you are
debugging via Visual Studio.NET, just go to Immediate window.
 Explain the three services model (three-tier application). Presentation (UI), business (logic and
underlying code) and data (from storage or other sources).
 What are advantages and disadvantages of Microsoft-provided data provider classes in
ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license
purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2,
Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the
world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.
 What’s the role of the DataReader class in ADO.NET connections? It returns a read-only dataset
from the data source when the command is executed.
 What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all
employees whose name starts with La. The wildcard character is %, the proper query with LIKE would
involve ‘La%’.
 Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work
and does not dependent on previous and following transactions), Consistent (data is either committed or
roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no
transaction sees the intermediate results of the current transaction), Durable (the values persist if the data
had been committed even if the system crashes right after).
 What connections does Microsoft SQL Server support? Windows Authentication (via Active
Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).
 Which one is trusted and which one is untrusted? Windows Authentication is trusted because the
username and password are checked with the Active Directory, the SQL Server authentication is untrusted,
since SQL Server is the only verifier participating in the transaction.
 Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows
applications.
 What does the parameter Initial Catalog define inside Connection String? The database name to
connect to.
 What’s the data provider name to connect to Access database? Microsoft.Access.
 What does Dispose method do with the connection object? Deletes it from the memory.
 What is a pre-requisite for connection pooling? Multiple processes must agree that they will share
the same connection, where every parameter is the same, including the security settings.

1. Is it possible to inline assembly or IL in C# code? - No.


2. Is it possible to have different access modifiers on the get/set methods of a property? - No.
The access modifier on a property applies to both its get and set accessors. What you need to do if
you want them to be different is make the property read-only (by only providing a get accessor)
and create a private/internal set method that is separate from the property.
3. Is it possible to have a static indexer in C#? - No. Static indexers are not allowed in C#.
4. If I return out of a try/finally in C#, does the code in the finally-clause run? - Yes. The code
in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the
try, the finally block always runs:
5. using System;
6.
7. class main
8. {
9. public static void Main()
10. {
11. try
12. {
13. Console.WriteLine("In Try block");
14. return;
15. }
16. finally
17. {
18. Console.WriteLine("In Finally block");
19. }
20. }
}

Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try
block or after the try-finally block, performance is not affected either way. The compiler treats it
as if the return were outside the try block anyway. If it’s a return without an expression (as it is
above), the IL emitted is identical whether the return is inside or outside of the try. If the return
has an expression, there’s an extra store/load of the value of the expression (since it has to be
computed within the try block).

21. I was trying to use an “out int” parameter in one of my functions. How should I declare the
variable that I am passing to it? - You should declare the variable as an int, but when you pass it
in you must specify it as ‘out’, like the following: int i; foo(out i); where foo is declared as
follows: [return-type] foo(out int o) { }
22. How does one compare strings in C#? - In the past, you had to call .ToString() on the strings
when using the == or != operators to compare the strings’ values. That will still work, but the C#
compiler now automatically compares the values instead of the references when the == or !=
operators are used on string types. If you actually do want to compare references, it can be done as
follows: if ((object) str1 == (object) str2) { … } Here’s an example showing how string compares
work:
23. using System;
24. public class StringTest
25. {
26. public static void Main(string[] args)
27. {
28. Object nullObj = null; Object realObj = new StringTest();
29. int i = 10;
30. Console.WriteLine("Null Object is [" + nullObj + "]\n"
31. + "Real Object is [" + realObj + "]\n"
32. + "i is [" + i + "]\n");
33. // Show string equality operators
34. string str1 = "foo";
35. string str2 = "bar";
36. string str3 = "bar";
37. Console.WriteLine("{0} == {1} ? {2}", str1, str2, str1 == str2 );
38. Console.WriteLine("{0} == {1} ? {2}", str2, str3, str2 == str3 );
39. }
40. }

Output:

Null Object is []
Real Object is [StringTest]
i is [10]
foo == bar ? False
bar == bar ? True
41. How do you specify a custom attribute for the entire assembly (rather than for a class)? -
Global attributes must appear after any top-level using clauses and before the first type or
namespace declarations. An example of this is as follows:
42. using System;
43. [assembly : MyAttributeClass] class X {}

Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.

44. How do you mark a method obsolete? -

[Obsolete] public int Foo() {...}

or

[Obsolete("This is a message describing why this method is obsolete")] public int Foo() {...}

Note: The O in Obsolete is always capitalized.

45. How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in


C#? - You want the lock statement, which is the same as Monitor Enter/Exit:
46. lock(obj) { // code }

translates to

try {
CriticalSection.Enter(obj);
// code
}
finally
{
CriticalSection.Exit(obj);
}

47. How do you directly call a native function exported from a DLL? - Here’s a quick example of
the DllImport attribute in action:
48. using System.Runtime.InteropServices; \
49. class C
50. {
51. [DllImport("user32.dll")]
52. public static extern int MessageBoxA(int h, string m, string c, int type);
53. public static int Main()
54. {
55. return MessageBoxA(0, "Hello World!", "Caption", 0);
56. }
57. }

This example shows the minimum requirements for declaring a C# method that is implemented in
a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers,
and has the DllImport attribute, which tells the compiler that the implementation comes from the
user32.dll, using the default name of MessageBoxA. For more information, look at the Platform
Invoke tutorial in the documentation.
58. How do I simulate optional parameters to COM calls? - You must use the Missing class and
pass Missing.Value (in System.Reflection) for any values that have optional parameters.

6. What does the term immutable mean?


The data value may not be changed. Note: The variable value may be changed, but the original immutable
data value was discarded and a new data value was created in memory.

7. What’s the difference between System.String and System.Text.StringBuilder classes?


System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable
string where a variety of operations can be performed.

Question 2. what is difference between primary key and foreign key?

Answer:
A primary key is a column, or set of columns which uniquely identify a record. For example; Department
table's primary key is the Dept number.
A foreign key is a column or set of columns in a table which have a corresponding relationship and a
dependency on another table, specifically the dependency is on the primary key of a table.

Posted By: ambesh kumar Answer Count : [2] Post Your Answer
Question 3. difference betwwen abstract class and interface with some code

Answer:
Interface :
1.Interface have only Signature.
2.All the Methods are Public , It doesn't have access Modifier Controls
3.It have used Multiple inheritence in the Object oriented Language.
Abstract Class:
1.Abstract Class have Method defination and Implementation
2.It have control the Access Modifiers
3.It does not allow multiple Inheritence

Posted By: prabhanjan reddy Answer Count : [2] Post Your Answer
Question 4. may i know wat is garrbage collection and how it can be implemented

Posted By: prabhanjan reddy Answer Count : [0] Post Your Answer
Question 5. what is cache

Answer:
cache is small memory which is placed in between cpu and main memoryy

Posted By: Nishant Sahu Answer Count : [1] Post Your Answer
Question 6. is any one tell me what is an interface?

Answer:
interface is which as as mediator betwwen user system and software device

Posted By: Navdeep verma Answer Count : [2] Post Your Answer
Question 7. List all collection available in c#?

Answer:
System.Collections.GenericsSystem.Collections
Comparer Comparer
Dictionary HashTable
List ArrayList
LinkedList
Queue Queue
SortedDictionary SortedList
SortedList
Stack Stack
ICollection ICollection
IComparable System.IComparable
IComparer

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 8. What are anonymous methods?

Answer:
In versions of C# previous to 2.0, the only way to declare a delegate was to use named methods. C# 2.0
introduces anonymous methods.

Creating anonymous methods is essentially a way to pass a code block as a delegate parameter. For
example:

// Create a delegate instance


delegate void Del(int x);

// Instantiate the delegate using an anonymous method


Del d = delegate(int k) { /* ... */ };

By using anonymous methods, you reduce the coding overhead in instantiating delegates by eliminating the
need to create a separate method.

For example, specifying a code block in the place of a delegate can be useful in a situation when having to
create a method might seem an unnecessary overhead.

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 9. What is Partial Class?

Answer:
Partial classes give you the ability to split a single class into more than one source code (.cs) file.

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 10. What is 'Auto Implemented Properties' in C# 3.0

Answer:
In c# 3.0 you need not write code to create get and set properties, following code :

public class Person


{
int _id;
string _firstName, _lastName;

public int ID
{
get{return _id;}
set{_id = value;}
}

public string FirstName


{
get{return _firstName;}
set{_firstName = value;}
}

public string LastName


{
get{return _lastName;}
set{_lastName = value;}
}
)

can be written as :

public class Person


{
public int ID { get; set; }
public string FirstName {get; set; }
public string LastName {get; set; }
}

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 11. What are Anonymous Types in C# 3.0

Answer:
In c# 3.0 you can create an instance of a class without having to write code for the class beforehand. So,
you now can write code as shown below:

new {city="Queens", state="NY", country="US"}

Behind the scenes, the C# compiler would create a class that looks as follows:

class __Anonymous123
{
private string _city = "Queens";
private string _state = "NY";
private int _country = "US";
public string city {get { return _city; } set { _city = value; }}
public string state {get { return _state; } set { _state= value; }}
public string country {get { return _country; } set { _country = value; }}
}

Posted By: QP Admin Answer Count : [2] Post Your Answer


Question 12. What is Implicitly Typed Local Variables in C# 3.0?

Answer:
C# 3.0 introduces a new keyword called "var".
Var allows you to declare a new variable, whose type is implicitly inferred
from the expression used to initialize the variable.
In other words, the following is valid syntax in C# 3.0:

var i = 1;

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 13. How do you inherit from a class in C#?

Answer:
to inherit a class we can use abstract classes, in which we have to instantiate the method into abstract class
since abstract functions do not have any body.e.g.
class a: class b
(
public void input(int a, int b);
public void output(int c, float d);
)

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 14. What is boxing?

Answer:
conversion from value type to reference type

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 15. What’s a delegate?

Answer:
Delegate is similar to function to pointers in C++, but are of type-safe references.It is a class which
encapsulates a method with a specific signature.
Need for a delegate is, when an object rises an event should be able to call different event handlers under
different circumstances.............

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 16. Differences between dataset.clone and dataset.copy?

Posted By: QP Admin Answer Count : [0] Post Your Answer


Question 17. What is Reflection in .NET?

Posted By: QP Admin Answer Count : [0] Post Your Answer


Question 18. What is the difference between in-proc and out-of-proc?

Posted By: QP Admin Answer Count : [0] Post Your Answer


Question 19. What is IDisposable interface?

Posted By: QP Admin Answer Count : [0] Post Your Answer


Question 20. What is the difference between Finalize() and Dispose()?

Posted By: QP Admin Answer Count : [0] Post Your Answer


Question 21. What is Reflection?

Posted By: QP Admin Answer Count : [0] Post Your Answer


Question 22. What is CLR?

Answer:
Common Language Runtime

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 23. What is the GAC? What problem does it solve?

Answer:
GAC is globel access cashe. It has public or shaired Assembilly.

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 24. What is a Windows Service and how does its life cycle differ from a "standard" executable
(exe)?

Posted By: QP Admin Answer Count : [0] Post Your Answer


Question 25. Whats the difference between a Thread and a Process?

Posted By: QP Admin Answer Count : [0] Post Your Answer


Question 26. What all Access Modifiers available in C#?

Answer:
Access modifiers are keywords used to specify the declared accessibility of a member or a type. Below is
list of Access Modifiers available in C#

public
protected
internal
private

The following five accessibility levels can be specified using the access modifiers:

public
protected
internal
internal protected
private

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 27. How to sort the elements of the array?
Answer:
Using Sort() method on array object.
To sort in descending order use Reverse() method after Sort()

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 28. What's the purpose of finally block in try..catch?

Answer:
finally block gets executed whether exception occured or not.

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 29. Whats the keyword to prevent class from being inherited by another class?

Answer:
sealed

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 30. Is it possible to assign null value to an integer variable in c#?

Answer:
Yes.
You can define nullable integer variable using following notation

DataTime? dt = null;

int? i = null;

bool? b = null;

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 31. Is it possible to inherit multiple classes in c#?

Answer:
No.
C# does not support multiple inheritance but you can achive multi-level inheritance in c#.

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 32. How to catch all exceptions in c# code?

Answer:
Use try...catch block to catch exceptions.
To catch all exception use base Exception class "Exception"

try
{

}
catch(Exception)
{

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 33. What's the base class in .NET?
Answer:
System.Object is base class.

Posted By: QP Admin Answer Count : [1] Post Your Answer


Question 34. Can you store multiple data types in System.Array?

Answer:
No

Posted By: QP Admin Answer Count : [2] Post Your Answer


Question 35. Describe advantage of using System.Text.StringBuilder over System.String?

Answer:
Strings are immutable, so each time it’s being operated on, a new instance is created.

What is "this" pointer?

Posted by: Abhisek | Show/Hide Answer


This pointer is a pointer which points to the current object of a class. this is actually a keyword which is
used as a pointer which differentiate the current object with global object.

--------------------------------SQL-------------------
1. What is normalization? - Well a relational database is basically composed of tables that contain
related data. So the Process of organizing this data into tables is actually referred to as
normalization.
2. What is a Stored Procedure? - Its nothing but a set of T-SQL statements combined to perform a
single task of several tasks. Its basically like a Macro so when you invoke the Stored procedure,
you actually run a set of statements.
3. Can you give an example of Stored Procedure? - sp_helpdb , sp_who2, sp_renamedb are a set of
system defined stored procedures. We can also have user defined stored procedures which can be
called in similar way.
4. What is a trigger? - Triggers are basically used to implement business rules. Triggers is also
similar to stored procedures. The difference is that it can be activated when data is added or edited
or deleted from a table in a database.
5. What is a view? - If we have several tables in a db and we want to view only specific columns
from specific tables we can go for views. It would also suffice the needs of security some times
allowing specfic users to see only specific columns based on the permission that we can configure
on the view. Views also reduce the effort that is required for writing queries to access specific
columns every time.
6. What is an Index? - When queries are run against a db, an index on that db basically helps in the
way the data is sorted to process the query for faster and data retrievals are much faster when we
have an index.
7. What are the types of indexes available with SQL Server? - There are basically two types of
indexes that we use with the SQL Server. Clustered and the Non-Clustered.
8. What is the basic difference between clustered and a non-clustered index? - The difference is that,
Clustered index is unique for any given table and we can have only one clustered index on a table.
The leaf level of a clustered index is the actual data and the data is resorted in case of clustered
index. Whereas in case of non-clustered index the leaf level is actually a pointer to the data in
rows so we can have as many non-clustered indexes as we can on the db.
9. What are cursors? - Well cursors help us to do an operation on a set of data that we retreive by
commands such as Select columns from table. For example : If we have duplicate records in a
table we can remove it by declaring a cursor which would check the records during retreival one
by one and remove rows which have duplicate values.
10. When do we use the UPDATE_STATISTICS command? - This command is basically used when
we do a large processing of data. If we do a large amount of deletions any modification or Bulk
Copy into the tables, we need to basically update the indexes to take these changes into account.
UPDATE_STATISTICS updates the indexes on these tables accordingly.
11. Which TCP/IP port does SQL Server run on? - SQL Server runs on port 1433 but we can also
change it for better security.
12. From where can you change the default port? - From the Network Utility TCP/IP properties –>
Port number.both on client and the server.
13. Can you tell me the difference between DELETE & TRUNCATE commands? - Delete command
removes the rows from a table based on the condition that we provide with a WHERE clause.
Truncate will actually remove all the rows from a table and there will be no data in the table after
we run the truncate command.
14. Can we use Truncate command on a table which is referenced by FOREIGN KEY? - No. We
cannot use Truncate command on a table with Foreign Key because of referential integrity.
15. What is the use of DBCC commands? - DBCC stands for database consistency checker. We use
these commands to check the consistency of the databases, i.e., maintenance, validation task and
status checks.
16. Can you give me some DBCC command options?(Database consistency check) - DBCC
CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC
CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It
gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP -
Checks all tables file group for any damage.
17. What command do we use to rename a db? - sp_renamedb ‘oldname’ , ‘newname’
18. Well sometimes sp_reanmedb may not work you know because if some one is using the db it will
not accept this command so what do you think you can do in such cases? - In such cases we can
first bring to db to single user using sp_dboptions and then we can rename that db and then we can
rerun the sp_dboptions command to remove the single user mode.
19. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE? - Having Clause
is basically used only with the GROUP BY function in a query. WHERE Clause is applied to each
row before they are part of the GROUP BY function in a query.
20. What do you mean by COLLATION? - Collation is basically the sort order. There are three types
of sort order Dictionary case sensitive, Dictonary - case insensitive and Binary.
21. What is a Join in SQL Server? - Join actually puts data from two or more tables into a single result
set.
22. Can you explain the types of Joins that we can have with Sql Server? - There are three types of
joins: Inner Join, Outer Join, Cross Join
23. When do you use SQL Profiler? - SQL Profiler utility allows us to basically track connections to
the SQL Server and also determine activities such as which SQL Scripts are running, failed jobs
etc..
24. What is a Linked Server? - Linked Servers is a concept in SQL Server by which we can add other
SQL Server to a Group and query both the SQL Server dbs using T-SQL Statements.
25. Can you link only other SQL Servers or any database servers such as Oracle? - We can link any
server provided we have the OLE-DB provider from Microsoft to allow a link. For Oracle we have
a OLE-DB provider for oracle that microsoft provides to add it as a linked server to the sql server
group.
26. Which stored procedure will you be running to add a linked server? - sp_addlinkedserver,
sp_addlinkedsrvlogin
27. What are the OS services that the SQL Server installation adds? - MS SQL SERVER SERVICE,
SQL AGENT SERVICE, DTC (Distribution transac co-ordinator)
28. Can you explain the role of each service? - SQL SERVER - is for running the databases SQL
AGENT - is for automation such as Jobs, DB Maintanance, Backups DTC - Is for linking and
connecting to other SQL Servers
29. How do you troubleshoot SQL Server if its running very slow? - First check the processor and
memory usage to see that processor is not above 80% utilization and memory not above 40-45%
utilization then check the disk utilization using Performance Monitor, Secondly, use SQL Profiler
to check for the users and current SQL activities and jobs running which might be a problem.
Third would be to run UPDATE_STATISTICS command to update the indexes
30. Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do
you troubleshoot? - First I will look to ensure that port settings are proper on server and client
Network utility for connections. ODBC is properly configured at client end for connection ——
Makepipe & readpipe are utilities to check for connection. Makepipe is run on Server and
readpipe on client to check for any connection issues.
31. What are the authentication modes in SQL Server? - Windows mode and mixed mode (SQL &
Windows).
32. Where do you think the users names and passwords will be stored in sql server? - They get stored
in master db in the sysxlogins table.
33. What is log shipping? Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature
of SQL Server 2000. We should have two SQL Server - Enterprise Editions. From Enterprise
Manager we can configure the logshipping. In logshipping the transactional log file from one
server is automatically updated into the backup database on the other server. If one server fails, the
other server will have the same db and we can use this as the DR (disaster recovery) plan.
34. Let us say the SQL Server crashed and you are rebuilding the databases including the master
database what procedure to you follow? - For restoring the master db we have to stop the SQL
Server first and then from command line we can type SQLSERVER –m which will
basically bring it into the maintenance mode after which we can restore the master db.
35. Let us say master db itself has no backup. Now you have to rebuild the db so what kind of action
do you take? - (I am not sure- but I think we have a command to do it).
36. What is BCP? When do we use it? - BulkCopy is a tool used to copy huge amount of data from
tables and views. But it won’t copy the structures of the same.
37. What should we do to copy the tables, schema and views from one SQL Server to another? - We
have to write some DTS packages for it.
38. What are the different types of joins and what dies each do?
39. What are the four main query statements?
40. What is a sub-query? When would you use one?
41. What is a NOLOCK?
42. What are three SQL keywords used to change or set someone’s permissions?
43. What is the difference between HAVING clause and the WHERE clause?
44. What is referential integrity? What are the advantages of it?
45. What is database normalization?
46. Which command using Query Analyzer will give you the version of SQL server and operating
system?
47. Using query analyzer, name 3 ways you can get an accurate count of the number of records in a
table?
48. What is the purpose of using COLLATE in a query?
49. What is a trigger?
50. What is one of the first things you would do to increase performance of a query? For example, a
boss tells you that “a query that ran yesterday took 30 seconds, but today it takes 6 minutes”
51. What is an execution plan? When would you use it? How would you view the execution plan?
52. What is the STUFF function and how does it differ from the REPLACE function?
53. What does it mean to have quoted_identifier on? What are the implications of having it off?
54. What are the different types of replication? How are they used?
55. What is the difference between a local and a global variable?
56. What is the difference between a Local temporary table and a Global temporary table? How is
each one used?
57. What are cursors? Name four types of cursors and when each one would be applied?
58. What is the purpose of UPDATE STATISTICS?
59. How do you use DBCC statements to monitor various aspects of a SQL server installation?
60. How do you load large data to the SQL server database?
61. How do you check the performance of a query and how do you optimize it?
62. How do SQL server 2000 and XML linked? Can XML be used to access data?
63. What is SQL server agent?
64. What is referential integrity and how is it achieved?
65. What is indexing?
66. What is normalization and what are the different forms of normalizations?
67. Difference between server.transfer and server.execute method?
68. What id de-normalization and when do you do it?
69. What is better - 2nd Normal form or 3rd normal form? Why?
70. Can we rewrite subqueries into simple select statements or with joins? Example?
71. What is a function? Give some example?
72. What is a stored procedure?
73. Difference between Function and Procedure-in general?
74. Difference between Function and Stored Procedure?
75. Can a stored procedure call another stored procedure. If yes what level and can it be controlled?
76. Can a stored procedure call itself(recursive). If yes what level and can it be controlled.?
77. How do you find the number of rows in a table?
78. Difference between Cluster and Non-cluster index?
79. What is a table called, if it does not have neither Cluster nor Non-cluster Index?
80. Explain DBMS, RDBMS?
81. Explain basic SQL queries with SELECT from where Order By, Group By-Having?
82. Explain the basic concepts of SQL server architecture?
83. Explain couple pf features of SQL server
84. Scalability, Availability, Integration with internet, etc.)?
85. Explain fundamentals of Data ware housing & OLAP?
86. Explain the new features of SQL server 2000?
87. How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?
88. What is data integrity? Explain constraints?
89. Explain some DBCC commands?
90. Explain sp_configure commands, set commands?
91. Explain what are db_options used for?
92. What is the basic functions for master, msdb, tempdb databases?
93. What is a job?
94. What are tasks?
95. What are primary keys and foreign keys?
96. How would you Update the rows which are divisible by 10, given a set of numbers in column?
97. If a stored procedure is taking a table data type, how it looks?
98. How m-m relationships are implemented?
99. How do you know which index a table is using?
100.How will oyu test the stored procedure taking two parameters namely first name and last name
returning full name?
101.How do you find the error, how can you know the number of rows effected by last SQL
statement?
102.How can you get @@error and @@rowcount at the same time?
103.What are sub-queries? Give example? In which case sub-queries are not feasible?
104.What are the type of joins? When do we use Outer and Self joins?
105.Which virtual table does a trigger use?
106.How do you measure the performance of a stored procedure?
107.Questions regarding Raiseerror?
108.Questions on identity?
109.If there is failure during updation of certain rows, what will be the state?

Database Concepts
What is a database or database management systems (DBMS)?
What’s difference between DBMS and RDBMS ?
What are CODD rules?
Is access database a RDBMS?
What’s the main difference between ACCESS and SQL SERVER?
What’s the difference between MSDE and SQL SERVER 2000?
What is SQL SERVER Express 2005 Edition?
What is SQL Server 2000 Workload Governor?
What’s the difference between SQL SERVER 2000 and 2005?
What are E-R diagrams?
How many types of relationship exist in database designing?
Can you explain Fourth Normal Form?
Can you explain Fifth Normal Form?
What’s the difference between Fourth and Fifth normal form?
Have you heard about sixth normal form?
What is Extent and Page?
What are the different sections in Page?
What are page splits?
In which files does actually SQL Server store data?
What is Collation in SQL Server?
Can we have a different collation for database and table?

SQL
Revisiting basic syntax of SQL?
What are “GRANT” and “REVOKE’ statements?
What is Cascade and Restrict in DROP table SQL?
What is a DDL, DML and DCL concept in RDBMS world?
What are different types of joins in SQL?
What is “CROSS JOIN”?
You want to select the first record in a given set of rows?
How do you sort in SQL?
How do you select unique rows using SQL?
Can you name some aggregate function is SQL Server?
What is the default “SORT” order for a SQL?
What is a self-join?
What's the difference between DELETE and TRUNCATE ?
Select addresses which are between ‘1/1/2004’ and ‘1/4/2004’?
What are Wildcard operators in SQL Server?
What’s the difference between “UNION” and “UNION ALL” ?
What are cursors and what are the situations you will use them?
What are the steps to create a cursor?
What are the different Cursor Types?
What are “Global” and “Local” cursors?
What is “Group by” clause?
What is ROLLUP?
What is CUBE?
What is the difference between “HAVING” and “WHERE” clause?
What is “COMPUTE” clause in SQL?
What is “WITH TIES” clause in SQL?
What does “SET ROWCOUNT” syntax achieves?
What is a Sub-Query?
What is “Correlated Subqueries”?
What is “ALL” and “ANY” operator?
What is a “CASE” statement in SQL?
What does COLLATE Keyword in SQL signify?

.NET Integration

What are steps to load a .NET code in SQL SERVER 2005?


How can we drop a assembly from SQL SERVER?
Are changes made to assembly updated automatically in database?
Why do we need to drop assembly for updating changes?
How to see assemblies loaded in SQL Server?
I want to see which files are linked with which assemblies?
Does .NET CLR and SQL SERVER run in different process?
Does .NET controls SQL SERVER or is it vice-versa?
Is SQLCLR configured by default?
How to configure CLR for SQL SERVER?
Is .NET feature loaded by default in SQL Server?
How does SQL Server control .NET run-time?
What’s a “SAND BOX” in SQL Server 2005?
What is a application domain?
How are .NET Appdomain allocated in SQL SERVER 2005?
What is Syntax for creating a new assembly in SQL Server 2005?
Do Assemblies loaded in database need actual .NET DLL?
Does SQL Server handle unmanaged resources?
What is Multi-tasking ?
What is Multi-threading ?
What is a Thread ?
Can we have multiple threads in one App domain ?
What is Non-preemptive threading?
What is pre-emptive threading?
Can you explain threading model in SQL Server?
How does .NET and SQL Server thread work?
How are exception in SQLCLR code handled?
Are all .NET libraries allowed in SQL Server?
What is “Hostprotectionattribute” in SQL Server 2005?
How many types of permission level are there for an assembly?
Can you name system tables for .NET assemblies?
Are two version of same assembly allowed in SQL Server?
How are changes made in assembly replicated?
Is it a good practice to drop a assembly for changes?
In one of the projects following steps where done, will it work?
What does Alter assembly with unchecked data signify?
How do I drop an assembly?
Can we creat SQLCLR using .NET framework 1.0?
While creating .NET UDF what checks should be done?
How do you define a function from the .NET assembly?
Can compare between T-SQL and SQLCLR ?
With respect to .NET is SQL SERVER case sensitive?
Does case sensitive rule apply for VB.NET?
Can nested classes be accessed in T-SQL?
Can we have SQLCLR procedure input as array?
Can object datatype be used in SQLCLR?
How’s precision handled for decimal datatypes in .NET?
How do we define INPUT and OUTPUT parameters in SQLCLR?
Is it good to use .NET datatypes in SQLCLR?
How to move values from SQL to .NET datatypes?
What is System.Data.SqlServer?
What is SQLContext?
Can you explain essential steps to deploy SQLCLR?
How do create function in SQL Server using .NET?
How do we create trigger using .NET?
How to create User Define Functions using .NET?
How to create User Defined Create aggregates using .NET?
What is Asynchronous support in ADO.NET?
What is MARS support in ADO.NET?
What is SQLbulkcopy object in ADO.NET ?
How to select range of rows using ADO.NET?

ADO.NET

Which are namespaces for ADO.NET?


Can you give a overview of ADO.NET architecture ?
What are the two fundamental objects in ADO.NET ?
What is difference between dataset and datareader ?
What are major difference between classic ADO and ADO.NET ?
What is the use of connection object ?
What are the methods provided by the command object ?
What is the use of dataadapter ?
What are basic methods of Dataadapter ?
What is Dataset object?
What are the various objects in Dataset ?
How can we connect to Microsoft Access , Foxpro , Oracle etc ?
What’s the namespace to connect to SQL Server?
How do we use stored procedure in ADO.NET?
How can we force the connection object to close?
I want to force the datareader to return only schema?
Can we optimize command object when there is only one row?
Which is the best place to store connectionstring ?
What are steps involved to fill a dataset ?
What are the methods provided by the dataset for XML?
How can we save all data from dataset ?
How can we check for changes made to dataset?
How can we add/remove row’s in “DataTable” object of “DataSet” ?
What’s basic use of “DataView” ?
What’s difference between “DataSet” and “DataReader” ?
How can we load multiple tables in a DataSet ?
How can we add relation’s between table in a DataSet ?
What’s the use of CommandBuilder ?
What’s difference between “Optimistic” and “Pessimistic” locking ?
How many way’s are there to implement locking in ADO.NET ?
How can we perform transactions in .NET?
What’s difference between Dataset. clone and Dataset. copy ?
Whats the difference between Dataset and ADO Recordset?

Notification Services

What are notification services?


What are basic components of Notification services?
Can you explain architecture of Notification Services?
Which are the two XML files needed for notification services?
What is Nscontrols command?
What are the situations you will use “Notification” Services?

Service Broker

What do we need Queues?


What is “Asynchronous” communication?
What is SQL Server Service broker?
What are the essential components of SQL Server Service broker?
What is the main purpose of having Conversation Group?
How to implement Service Broker?
How do we encrypt data between Dialogs?

XML Integration

What is XML?
What is the version information in XML?
What is ROOT element in XML?
If XML does not have closing tag will it work?
Is XML case sensitive?
What’s the difference between XML and HTML?
Is XML meant to replace HTML?
Can you explain why your project needed XML?
What is DTD (Document Type definition)?
What is well formed XML?
What is a valid XML?
What is CDATA section in XML?
What is CSS?
What is XSL?
What is Element and attributes in XML?
Can we define a column as XML?
How do we specify the XML data type as typed or untyped?
How can we create the XSD schema?
How do I insert in to a table which has XSD schema attached to it?
What is maximum size for XML datatype?
What is Xquery?
What are XML indexes?
What are secondary XML indexes?
What is FOR XML in SQL Server?
Can I use FOR XML to generate SCHEMA of a table and how?
What is the OPENXML statement in SQL Server?
I have huge XML file which we want to load in database?
How to call stored procedure using HTTP SOAP?
What is XMLA ?

Data Warehousing/Data Mining

What is “Data Warehousing”?


What are Data Marts?
What are Fact tables and Dimension Tables?
What is Snow Flake Schema design in database?
What is ETL process in Data warehousing?
How can we do ETL process in SQL Server?
What is “Data mining”?
Compare “Data mining” and “Data Warehousing”?
What is BCP?
How can we import and export using BCP utility?
What is Bulk Insert?
What is DTS ?
Can you brief about the Data warehouse project you worked on?
What is an OLTP (Online Transaction Processing) System?
What is an OLAP (On-line Analytical processing) system?
What is Conceptual, Logical and Physical model?
What is Data purging?
What is Analysis Services?
What are CUBES?
What are the primary ways to store data in OLAP?
What is META DATA information in Data warehousing projects?
What is multi-dimensional analysis?
What is MDX?
How did you plan your Data ware house project?
What are different deliverables according to phases?
Can you explain how analysis service works?
What are the different problems that “Data mining” can solve?
What are different stages of “Data mining”?
What is Discrete and Continuous data in Data mining world?
What is MODEL is Data mining world?
How are models actually derived?
What is a Decision Tree Algorithm?
Can decision tree be implemented using SQL?
What is Naïve Bayes Algorithm?
Explain clustering algorithm?
Explain in detail Neural Networks?
What is Back propagation in Neural Networks?
What is Time Series algorithm in data mining?
Explain Association algorithm in Data mining?
What is Sequence clustering algorithm?
What are algorithms provided by Microsoft in SQL Server?
How does data mining and data warehousing work together?
What is XMLA ?
What is Discover and Execute in XMLA?

Integration Services/DTS

What is Integration Services import / export wizard?


What are prime components in Integration Services?
How can we develop a DTS project in Integration Services?

Replication

Whats the best way to update data between SQL Servers?


What are the scenarios you will need multiple databases with schema?
How will you plan your replication?
What is a publisher, distributor and subscriber in “Replication”?
What is “Push” and “Pull” subscription?
Can a publication support push and pull at one time?
What are different models / types of replication?
What is Snapshot replication?
What are the advantages and disadvantages of using Snapshot replication?
What type of data will qualify for “Snapshot replication”?
What’s the actual location where the distributor runs?
Can you explain in detail how exactly “Snapshot Replication” works?
What is merge replication?
How does merge replication works?
What are advantages and disadvantages of Merge replication?
What is conflict resolution in Merge replication?
What is a transactional replication?
Can you explain in detail how transactional replication works?
What are data type concerns during replications?

Reporting Services

Can you explain how can we make a simple report in reporting services?
How do I specify stored procedures in Reporting Services?
What is the architecture for “Reporting Services “?

Database Optimization

What are indexes?


What are B-Trees?
I have a table which has lot of inserts, is it a good database design to create indexes on that table?
What are “Table Scan’s” and “Index Scan’s”?
What are the two types of indexes and explain them in detail?
What is “FillFactor” concept in indexes?
What is the best value for “FillFactor”?
What are “Index statistics”?
How can we see statistics of an index?
How do you reorganize your index, once you find the problem?
What is Fragmentation?
How can we measure Fragmentation?
How can we remove the Fragmented spaces?
What are the criteria you will look in to while selecting an index?
What is “Index Tuning Wizard”?
What is an Execution plan?
How do you see the SQL plan in textual format?
What is nested join, hash join and merge join in SQL Query plan?
What joins are good in what situations? 298

Transaction and Locks

What is a “Database Transactions “?


What is ACID?
What is “Begin Trans”, “Commit Tran”, “Rollback Tran” and “Save Tran”?
What are “Checkpoint’s” in SQL Server?
What are “Implicit Transactions”?
Is it good to use “Implicit Transactions”?
What is Concurrency?
What kind of problems occurs if we do not implement proper locking strategy?
What are “Dirty reads”?
What are “Unrepeatable reads”?
What are “Phantom rows”?
What are “Lost Updates”?
What are different levels of granularity of locking resources?
What are different types of Locks in SQL Server?
What are different Isolation levels in SQL Server?
If you are using COM+ what “Isolation” level is set by default?
What are “Lock” hints?
What is a “Deadlock” ?
What are the steps you can take to avoid “Deadlocks” ?
How can I know what locks are running on which resource?

You might also like