Thursday, December 26, 2013

FAQ Sql Server 2008 Question And Answer



What is denormalization and when would you go for it?
As the name indicates, denormalization is the reverse process of normalization. It's the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.

How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?
One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships. One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships. Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.

What's the difference between a primary key and a unique key?
Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

What are user defined datatypes and when you should go for them?
User defined datatypes let you extend the base SQL Server datatypes by providing a descriptive name, and format to the database. Take for example, in your database, there is a column called ZIP_Code which appears in many tables. In all these tables it should be varchar(6). In this case you could create a user defined datatype called ZIP_Code_Type of varchar(6) and use it across all your tables.

What is bit datatype and what's the information that can be stored inside a bit column?
Bit datatype is used to store boolean information like 1 or 0 (true or false). Untill SQL Server 6.5 bit datatype could hold either a 1 or 0 and there was no support for NULL. But from SQL Server 7.0 onwards, bit datatype can represent a third state, which is NULL.

Define candidate key, alternate key, composite key.
A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys. A key formed by combining at least two or more columns is called composite key.

What are defaults? Is there a column to which a default can't be bound?
A default is a value that will be used by a column, if no value is supplied to that column while inserting data. IDENTITY columns and timestamp columns can't have defaults bound to them. See CREATE DEFUALT in books online.

What is a transaction and what are ACID properties?
A transaction is a logical unit of work in which, all the steps must be performed or none. ACID stands for Atomicity, Consistency, Isolation, Durability. These are the properties of a transaction. For more information and explanation of these properties, see SQL Server books online or any RDBMS fundamentals text book.

Explain different isolation levels An isolation level determines the degree of isolation of data between concurrent transactions.
The default SQL Server isolation level is Read Committed. Here are the other isolation levels (in the ascending order of isolation): Read Uncommitted, Read Committed, Repeatable Read, Serializable.

How does .NET and SQL SERVER thread is work?
There are two types of threading pre-emptive and Non-preemptive but Sql Server support Non-preemptive and .NET thread model is different. Because Sql have to handle thread in different way for SQLCLR this different thread are known as Tasking of Threads . In this thread there is a switch between SQLCLR and SQL SERVER threads .SQL SERVER uses blocking points for transition to happen between SQLCLR and SQL SERVER threads.

What's the maximum size of a row?
8060 bytes.

What is lock escalation?
Strong names are required to store shared assemblies in the global assembly cache (GAC). This is because the GAC allows multiple versions of the same assembly to reside on your system simultaneously, so that each application can find and use its own version of your assembly. This helps avoid DLL Hell, where applications that may be compiled to different versions of your assembly could potentially break because they are all forced to use the same version of your assembly. Another reason to use strong names is to make it difficult for hackers to spoof your assembly, in other words, replace or inject your assembly with a virus or malicious code.

What's the difference between DELETE TABLE and TRUNCATE TABLE commands?
DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also 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. Of course, TRUNCATE TABLE can be rolled back.

What are constraints? Explain different types of constraints.
Constraints enable the RDBMS enforce the integrity of the database automatically, without needing you to create triggers, rule or defaults. Types of constraints: NOT NULL, CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY 

What is an index?
Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quicker.

What are the types of indexes?
Indexes are of two types. Clustered indexes and non-clustered indexes. When you craete a clustered index on a table, all the rows in the table are stored in the order of the clustered index key. So, there can be only one clustered index per table. Non-clustered indexes have their own storage separate from the table data storage. Non-clustered indexes are stored as B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and it's row locater. The row located could be the RID or the Clustered index key, depending up on the absence or presence of clustered index on the table.

I create a separate index on each column of a table. what are the advantages and disadvantages of this approach?
If you create an index on each column of a table, it improves the query performance, as the query optimizer can choose from all the existing indexes to come up with an efficient execution plan. At the same t ime, data modification operations (such as INSERT, UPDATE, DELETE) will become slow, as every time data changes in the table, all the indexes need to be updated. Another disadvantage is that, indexes need disk space, the more indexes you have, more disk space is used.

What is RAID and what are different types of RAID configurations?
RAID stands for Redundant Array of Inexpensive Disks, used to provide fault tolerance to database servers. There are six RAID levels 0 through 5 offering different levels of performance, fault tolerance.

What are the steps you will take, if you are tasked with securing an SQL Server?
Preferring NT authentication, using server, databse and application roles to control access to the data, securing the physical database files using NTFS permissions, using an unguessable SA password, restricting physical access to the SQL Server, renaming the Administrator account on the SQL Server computer, disabling the Guest account, enabling auditing, using multiprotocol encryption, setting up SSL, setting up firewalls, isolating SQL Server from the web server etc.

What is a deadlock and what is a live lock? How will you go about resolving deadlocks?
Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the other's piece. Each process would wait indefinitely for the other to release the lock, unless one of the user processes is terminated. SQL Server detects deadlocks and terminates one user's process. A livelock is one, where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.

What is blocking and how would you troubleshoot it?
Blocking happens when one connection from an application holds a lock and a second connection requires a conflicting lock type. This forces the second connection to wait, blocked on the first.

How to restart SQL Server in single user mode?
SQL Server can be started from command line, using the SQLSERVR.EXE. This EXE has some very important parameters with which a DBA should be familiar with. -m is used for starting SQL Server in single user mode and -f is used to start the SQL Server in minimal confuguration mode.

what are the DBCC commands that you commonly use for database maintenance?
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.

What are statistics?
Statistics determine the selectivity of the indexes. If an indexed column has unique values then the selectivity of that index is more, as opposed to an index with non-unique values. Query optimizer uses these indexes in determining whether to choose an index or not while executing a query.

Under what circumstances they go out of date, how do you update statistics?
Some situations under which you should update statistics:
1) If there is significant change in the key values in the index
2) If a large amount of data in an indexed column has been added, changed, or removed (that is, if the distribution of key values has changed), or the table has been truncated using the TRUNCATE TABLE statement and then repopulated
3) Database is upgraded from a previous version Look up SQL Server books online for the following commands: UPDATE STATISTICS, STATS_DATE, DBCC SHOW_STATISTICS, CREATE STATISTICS, DROP STATISTICS, sp_autostats, sp_createstats, sp_updatestats

What are the different ways of moving data/databases between servers and databases in SQL Server?
BACKUP/RESTORE, dettaching and attaching databases, replication, DTS, BCP, logshipping, INSERT...SELECT, SELECT...INTO, creating INSERT scripts to generate data.

Explian different types of BACKUPs avaialabe in SQL Server?
Full database backup, differential database backup, transaction log backup, filegroup backup.

What is database replicaion?
Replication is the process of copying/moving data between databases on the same or different servers.

What are the different types of replication you can set up in SQL Server?
SQL Server supports the following types of replication scenarios:
* Snapshot replication
* Transactional replication (with immediate updating subscribers, with queued updating subscribers)
* Merge replication

How to determine the service pack currently installed on SQL Server?
The global variable @@Version stores the build number of the sqlservr.exe, which is used to determine the service pack installed.

What are cursors?
 Cursors allow row-by-row prcessing of the resultsets.
Explain different types of cursors.
Types of cursors:
Static, Dynamic, Forward-only, Keyset-driven.

What are the disadvantages of cursors?
Disadvantages of cursors:
Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.

How can you avoid cursors?
Most of the times, set based operations can be used instead of cursors. Another situation in which developers tend to use cursors: You need to call a stored procedure when a column in a particular row meets certain condition. You don't have to use cursors for this. This can be achieved using WHILE loop, as long as there is a unique key to identify each row.

What is a join?
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.
Explain different types of joins.
Types of joins:
INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.

Can you have a nested transaction?
Yes, very much.
What is an extended stored procedure?
An extended stored procedure is a function within a DLL (written in a programming language like C, C++ using Open Data Services (ODS) API) that can be called from T-SQL, just the way we call normal stored procedures using the EXEC statement.

Can you instantiate a COM object by using T-SQL?
Yes, you can instantiate a COM (written in languages like VB, VC++) object from T-SQL by using sp_OACreate stored procedure. 

What is the system function to get the current user's user id?
USER_ID(). Some more system functions: USER_NAME(), SYSTEM_USER, SESSION_USER, CURRENT_USER, USER, SUSER_SID(), HOST_NAME().

What are triggers?
Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table.

How many triggers you can have on a table?
In SQL Server 6.5 you could define only 3 triggers per table, one for INSERT, one for UPDATE and one for DELETE. From SQL Server 7.0 onwards, this restriction is gone, and you could create multiple triggers per each action.

How to invoke a trigger on demand?
In SQL Server 7.0 there's no way to control the order in which the triggers fire. In SQL Server 2000 you could specify which trigger fires first or fires last using sp_settriggerorder Triggers can't be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined. 

What are the uses of Triggers?
Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster. Till SQL Server 7.0, triggers fire only after the data modification operation happens. So in a way, they are called post triggers. But in SQL Server 2000 you could create pre triggers also. Search SQL Server 2000 books online for INSTEAD OF triggers.
What is a self join? Explain it with an example.
Self join is just like any other join, except that two instances of the same table will be joined in the query. Here is an example: Employees table which contains rows for normal employees as well as managers. So, to find out the managers of all the employees, you need a self join. 

What is normalization?
The Process of organizing relational data into tables is actually referred to as normalization.

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.

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.

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.

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.

Which TCP/IP port does SQL Server run on?
SQL Server runs on port 1433 but we can also change it for better security.

From where can you change the default port?
From the Network Utility TCP/IP properties –> Port number.both on client and the server.

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.

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.

What command do we use to rename a db?
sp_renamedb ‘oldname’ , ‘newname’
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. 

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.

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.

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..

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.

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.

Which stored procedure will you be running to add a linked server?
sp_addlinkedserver, sp_addlinkedsrvlogin

What are the OS services that the SQL Server installation adds?
MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac co-ordinator)

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

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

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.

What are the authentication modes in SQL Server?
Windows mode and mixed mode (SQL & Windows).

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.

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.

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.

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.

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.

FAQ Dot Net Question And Answer



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.

What’s the implicit name of the parameter that gets passed into the class’ set method?
Value, and it’s datatype depends on whatever variable we’re changing.

How do you inherit from a class in C#?
Place a colon and then the name of the base class.

Does C# support multiple inheritance?
No, use interfaces instead.

When you inherit a protected class-level variable, who is it available to?
Classes in the same namespace.

Are private class-level variables inherited?
Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

Describe the accessibility modifier protected internal.
It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).

C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.

What’s the top .NET class that everything is derived from?
System.Object.

How’s method overriding different from overloading?
When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.

What does the keyword virtual mean in the method definition?
The method can be over-ridden.

Can you declare the override method static while the original method is non-static?
No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

Can you override private virtual methods?
No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.

Can you prevent your class from being inherited and becoming a base class for some other classes?
Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.

Can you allow class to be inherited, but prevent the method from being over-ridden?
Yes, just leave the class public and make the method sealed.

What’s an abstract class?
A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it’s a blueprint for a class without any implementation.

When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?
When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.

What’s an interface class?
It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.

Why can’t you specify the accessibility modifier for methods inside the interface?
They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.

Can you inherit multiple interfaces?
Yes, why not.

And if they have conflicting method names?
It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.

What’s the difference between an interface and abstract class?
In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.

How can you overload a method?
Different parameter data types, different number of parameters, different order of parameters.

If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class. 

What’s the difference between System.String and System.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. 

Is it namespace class or class namespace?
The .NET class library is organized into namespaces. Each namespace contains a functionally related group of classes so natural namespace comes first.


Tuesday, December 24, 2013

passing data from one xaml to second xaml

passing data from one xaml to second xaml

Main.xaml

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;

namespace SilverlightApplication2
{
public partial class MainPage : UserControl
{
IsolatedStorageSettings ar = IsolatedStorageSettings.ApplicationSettings;

public MainPage()
{
InitializeComponent();
}

private void button1_Click(object sender, RoutedEventArgs e)
{
string y = "Maneesh";
ar["temp"] = y;
this.Content=new second();
}
}
}

Second.xaml

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
namespace SilverlightApplication2
{
public partial class second : UserControl
{
IsolatedStorageSettings ar = IsolatedStorageSettings.ApplicationSettings;

public second()
{
InitializeComponent();
}

private void button1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(ar["temp"].ToString());
}
}
}

general Ask ......Dot Net and Sql Server Question

Q 1 >What Is CLR ?
Q 2 What is CLR HOST?
Q 3 What is CTS?
Q 4 What is CLS?
Q 5 What is an Intermediate Language?
Q 6 What is Just In Time Compiler?
Q 7 What is Portable executable (PE)?
Q 8 What is Managed Code?
Q 9 What is UnManaged Code?
Q 10 What is Garbage Collector?
Q 11 >What is a Strong Name?
Q 12 What are the steps to create Strong Name?
Q 13 What are the Problems faced using Strong Name?
Q 14 What is Program Database?
Q 15 What is Delay Signing?
Q 16 What is an Assembly?
Q 17 What are the Contents of an Assembly?
Q 18 What are the Types of an Assemblies?
Q 19 What is a Satellite assembly?
Q 20 What are the Steps to Create Satellite Assembly?
Q 21 >What is an Assembly Loader?
Q 22 What is Multi Module Assembly or Assembly Linker?
Q 23 What is an Assembly Manifest?
Q 24 What is a Metadata?
Q 25 What is a Base class in .Net?
Q 26 What is Full Assembly Reference?
Q 27 What is Partial Assembly Reference?
Q 28 What is an Assembly Qualified Name?
Q 29 What is ILDASM (Intermediate Language Disassembler)?
Q 30 What is Global Assembly Cache?
Q 31 >What is an Attribute?
Q 32 What is Serialization & DeSerialization?
Q 33 Where Serialization is used?
Q 34 What are the types of Serialization available in .net?
Q 35 What is Binary Serialization?
Q 36 What are the Advantages & Disadvantages of Binary Serialization?
Q 37 What is SOAP Serialization?
Q 38 What are the Advantages of SOAP Serialization?
Q 39 What is a XML Serialization?
Q 40 What are the Advantages of XML Serialization?
Q 41 >What is Custom Serialization?
Q 42 What is a Namespace?
Q 43 What is GUID?
Q 44 What is a Formatter?
Q 45 What is a Binary Formatter?
Q 46 What is a SOAP Formatter?
Q 47 What is Reflection?
Q 48 What is Thread and Process?
Q 49 What are the difference between a Dll and an Exe?
Q 50 What are Globalization and Localization?
Q 51 >What is a Resource File?
Q 52 What is Code Access Security(CAS)?
Q 53 What is difference between Code Based Security and Role Based Security?
Q 54 What is difference between Invoke and Begin Invoke
Q 55 What is the difference between Debug and Trace?
Q 56 What is a Debug version of a code?
Q 57 What is a Release version of a code?
Q 58 What is an IDisposable Interface?
Q 59 What is Finalize block in .net?
Q 60 What is Dispose block in .net?
Q 61 >What is Runtime Host?
Q 62 What is Connection Pooling?
Q 63 What are the main parameters used by Connection Pooling?
Q 64 What is Connection Pool Manager?
Q 65 What is Object Pooling?
Q 66 What are the Advantages of Object Pooling?
Q 67 What is the Difference between Connection Pooling and Object Pooling?
Q 68 What is an Indexer?
Q 69 What are the important points to remember on indexers?
Q 70 What is the Difference between Indexers and Properties?
Q 71 >What are the different Access Modifiers available?
Q 72 What are the differences between Class and Struts?
Q 73 What are the Similarities between Class and Struts?
Q 74 What is the term Virtual means?
Q 75 What is a Sealed Class?
Q 76 What is Polymorphism?
Q 77 What are the Types of Polymorphism?
Q 78 What is Method Overloading? Or What is Early Binding?
Q 79 What is Method Overriding or What is Late Binding?
Q 80 What is an Inheritance?
Q 81 >What are the Types of Inheritance?
Q 82 What is Multiple Inheritance?
Q 83 What are the examples of Multiple Inheritance?
Q 84 What are the Advantages of Inheritance?
Q 85 What is an Encapsulation?
Q 86 What are the examples of Encapsulation?
Q 87 What is an Abstraction?
Q 88 What are the examples of Abstraction?
Q 89 Difference between Encapsulation and Abstraction ?
Q 90 What is an Abstract Class?
Q 91 >What is an Interface?
Q 92 What is a difference between Abstract Class and Interface?
Q 93 What is a Constructor?
Q 94 What is a Constructor chaining?
Q 95 What are the Types of constructors?
Q 96 What is a Private Constructor?
Q 97 What is a Static Constructors?
Q 98 What are the features of Static Constructor?
Q 99 What is a Default Constructor?
Q 100 What is a COPY Constructor?
Q 101 >What is a Parameterized constructor?
Q 102 What is a Singleton Class?
Q 103 What is a Partial Class?
Q 104 What is a Partial Method?
Q 105 What is a Delegate?
Q 106 What is a Syntax of Single class delegate?
Q 107 What are the advantages of Delegates?
Q 108 What is a Multicast Delegate?
Q 109 What is an Event?
Q 110 What is a Hash Table?
Q 111 >What is the Constructor of Hashtable?
Q 112 What is an Array?
Q 113 What is a Single-dimensional arrays?
Q 114 What is a Multidimensional arrays?
Q 115 What are Jagged arrays?
Q 116 What are Mixed Arrays?
Q 117 What is an ArrayList?
Q 118 What is the difference between Array and Array List?
Q 119 What is the Difference between Array and Collections?
Q 120 What is the difference between Array.Copy and Array.Clone?
Q 121 >What is a Shallow Copy?
Q 122 What is a Deep Copy?
Q 123 What are the different String Compare options available?
Q 124 What is a Statics Class
Q 125 What are the advantages of using Static Class?
Q 126 List some of the main features of a Static Class?
Q 127 What is a Static Member?
Q 128 What is a Static Variable?
Q 129 What is a Static Method?
Q 130 What is a Nested Class?
Q 131 >What is Shadowing or Hiding?
Q 132 What are Out and Ref parameters?
Q 133 What are the differences of Out and Ref Parameters?
Q 134 What are the differences between String and String Builder?
Q 135 Why C# is strongly typed language?
Q 136 What are Imperative and Interrogative function?
Q 137 What is a Collection Class?
Q 138 What are the differences between Const & Readonly?
Q 139 What is a Stack?
Q 140 What is a Heap?
Q 141 >What are Value Types?
Q 142 What are Reference Types?
Q 143 What are Boxing and UnBoxing means?
Q 144 What is Early Binding?
Q 145 What is Late Binding?
Q 146 What are the different WCF binding available?
Q 147 What is a BasicHttpBinding?
Q 148 What is a WSHttpBinding?
Q 149 What is a NetTcpBinding?
Q 150 What is a WSDualHttpBinding?
Q 151 >What is an ASP.NET Application and Page Life Cycle?
Q 152 What are the Steps for ASP.net environment creation?
Q 153 What is the ASP.NET Page Life Cycle?
Q 154 What is a Directive in ASP.Net?
Q 155 What are the different Validation Controls in ASP.Net?
Q 156 What is the Difference between User Control and Custom Control?
Q 157 What is the Difference between Client Side and Server Side Code?
Q 158 What is the Difference between Server.Transfer and Response.Redirect?
Q 159 What are the different IIS Isolation Levels in ASP.Net?
Q 160 What are the different Authentication Modes available in ASP.Net?
Q 161 >What is Windows Authentication Mode in ASP.Net?
Q 162 What are the advantages and disadvantages of Windows Authentication Mode?
Q 163 What is Form Authentication Mode in ASP.Net?
Q 164 What are the advantages and disadvantages of Form Authentication Mode?
Q 165 What is Passport Authentication Mode in ASP.Net?
Q 166 What are the advantages and disadvantages of Passport Authentication Mode?
Q 167 What is None Authentication Mode in ASP.Net?
Q 168 What are the advantages and disadvantages of None Authentication Mode?
Q 169 What are the different IIS authentications available?
Q 170 What is an Event Bubbling?
Q 171 >What are the differences between Machine.Config and a Web.Config files in Asp.Net?
Q 172 What is an Authentication?
Q 173 What is an Authorization?
Q 174 What is an Impersonation?
Q 175 What is Autopostback event in ASP.Net?
Q 176 What is Tracing in ASP.Net
Q 177 What is Scavenging?
Q 178 What are Trace Listeners?
Q 179 What is the difference between Respose.Write and Response.Output.Write?
Q 180 What is SmartNavigation?
Q 181 >What is a State Management in ASP.Net?
Q 182 What are the different management objects available with Client & Server Side Stage Management?
Q 183 How to Pass values between pages?
Q 184 What is a View State?
Q 185 What are the Benefits of ViewState?
Q 186 What are the Limitations of ViewState?
Q 187 What is an EnableViewState in ASP.Net?
Q 188 What are Hidden Fields in ASP.Net?
Q 189 What are the Benefits of Hidden Fields in ASP.Net?
Q 190 What are the Limitations of Hidden Fields in ASP.Net?
Q 191 >What are Hidden Frames in ASP.Net?
Q 192 What are the Benefits of Hidden Frames in ASP.Net?
Q 193 What are the Limitations of Hidden Frames in ASP.Net?
Q 194 What is a Cookie in ASP.Net?
Q 195 What are the examples of Cookie usage in ASP.Net?
Q 196 What are the Types of Cookies in ASP.Net?
Q 197 What are the Benefits of Cookies in ASP.Net?
Q 198 What are the Limitations of Cookies in ASP.Net?
Q 199 What is the relation between Cookies and Session State?
Q 200 What is a Cookieless Session in ASP.Net?
Q 201 >What are the Advantages of Session?
Q 202 What are the Disadvantages of Session?
Q 203 What is an In Proc Mode of storing sessions?
Q 204 What are the Advantages of InProc Sessions?
Q 205 What are the Disadvantages of InProc Sessions?
Q 206 What is a State Server Mode of Storing Sessions?
Q 207 What are the Advantages of State Server Session?
Q 208 What are the Disadvantages of State Server Session?
Q 209 What is a SQL Server Mode of Storing Session?
Q 210 What are the Advantages of SQL Server mode Session?
Q 211 >What are the Disadvantages of SQL Server modes?
Q 212 What is Custom Session Mode in ASP.Net?
Q 213 What are the Advantages of using Custom Session Mode in ASP.Net?
Q 214 What are the Disadvantages of using Custom Session Mode in ASP.Net?
Q 215 What is a Query String in ASP.Net?
Q 216 What are the Benefits of a Query String in ASP.Net?
Q 217 What are the Limitations of a Query String in ASP.Net?
Q 218 What is Cross Page Posting in ASP.Net?
Q 219 What is SQL Cache Dependency in ASP.Net?
Q 220 What is Global.asax in ASP.Net?
Q 221 >What are the Event available in Global.asax?
Q 222 What is Caching in ASP.Net?
Q 223 What are the Types of Caching in ASP.Net?
Q 224 How to cache different versions of the same page in ASP.Net?
Q 225 What is a Fragment Cache in ASP.Net?
Q 226 What are Resource Files in ASP.Net?
Q 227 What are the Types of Resource Files available in ASP.Net?
Q 228 What is a Local Resource File in ASP.Net?
Q 229 What is a Global Resource File in ASP.Net?
Q 230 What are the main tags in Web.Config file of ASP.Net application?
Q 231 >What is the use of <compilation> tag in ASP.Net Web.Config File?
Q 232 What is the use of <customErrors> tag in ASP.Net Web.Config File?
Q 233 What is the use of <globalization> tag in ASP.Net Web.Config File?
Q 234 What is the use of <httpRuntime> tag in ASP.Net Web.Config File?
Q 235 What is the use of <trace> tag in ASP.Net Web.Config File?
Q 236 What is the use of <identity> tag in ASP.Net Web.Config File?
Q 237 What is the use of <sessionState> tag in ASP.Net Web.Config File?
Q 238 What is the use of <appSettings> tag in ASP.Net Web.Config File?
Q 239 What is HTTP GET in ASP.Net?
Q 240 What is HTTP POST in ASP.Net?
Q 241 >What is Normalization in SQL Server?
Q 242 What is a De-Normalization in SQL Server?
Q 243 What are the different Normalization Forms in SQL Server?
Q 244 What is a Stored Procedure in SQL Server?
Q 245 What are the Advantages of Stored Procedure in SQL Server?
Q 246 What are the DisAdvantages of Stored Procedure in SQL Server?
Q 247 What is a User Defined Functions in SQL Server?
Q 248 What is a Scalar value-returning User Defined Function in SQL Server?
Q 249 What is an In Line Table User Defined Function in SQL Server?
Q 250 What is a Multistatement Table User Defined Function in SQL Server?
Q 251 >What are the Advantages of User Defined Functions?
Q 252 What are the DisAdvantages of User Defined Functions?
Q 253 What is the difference between a Stored Procedure and Functions?
Q 254 What is a Trigger?
Q 255 What is a DML Trigger?
Q 256 What is a DDL Trigger?
Q 257 What is a CLR Trigger?
Q 259 What are the DisAdvantages of Triggers?
Q 260 What are Views in SQL Server?
Q 261 >What are the Types of VIEW?
Q 262 How Views ensure security of data?
Q 263 List some of the common examples of views?
Q 264 What are the Limitations of views?
Q 265 What are Linked Servers in SQL Server?
Q 266 What are the Advantages of Linked Servers?
Q 267 What is a Cursor in SQL Server?
Q 268 What are the steps to Create Cursor in SQL Server?
Q 269 What are the Types of Cursors in SQL Server?
Q 270 What are the Cursor Optimization Tips available?
Q 271 >What are the Cursor Alternatives?
Q 272 What are the Limitations of Cursors?
Q 273 What is a SubQuery?
Q 274 What are the Properties of Subquery?
Q 275 What are the Types of Subquery?
Q 276 What is a Correlated Subquery?
Q 277 What are the Properties of Correlated Subquery?
Q 278 What are the different Authentication options and Authentication Modes in SQL Server?
Q 279 What is a Windows Authentication Mode?
Q 280 What is a Mixed Authentication Mode(Windows Authentication and SQL Server Authentication)?
Q 281 >How to Select an Authentication Mode in SQL Server?
Q 282 What is an Identity?
Q 283 What are INNER JOINs in SQL?
Q 284 What is a LEFT OUTER JOIN in SQL?
Q 285 What is a RIGHT OUTER JOIN in SQL?
Q 286 What is a FULL OUTER JOIN in SQL?
Q 287 What is an EQUI JOIN in SQL?
Q 288 What is a CROSS JOIN in SQL?
Q 289 What is a SELF JOIN in SQL?
Q 290 What is a NATURAL JOIN in SQL?
Q 291 >What is Log shipping?
Q 292 What is an Index?
Q 293 How to Create an Effective Index?
Q 294 What are the Types of Indexes available?
Q 295 What is the difference between Primary Key and a Unique Key?
Q 296 What is the difference between Delete and a Truncate?
Q 297 What is a Clustered Index?
Q 298 What is a Non Clustered Index?
Q 299 What is the difference between Clustered and Non Clustered Index?
Q 300 What is BCP used in SQL?
Q 301 >What is the use of Having and Where Clause in SQL?
Q 302 What is the difference between Having and Where Clause in SQL?
Q 303 What is the Local Temporary Table?
Q 304 What is the Global Temporary Table?
Q 305 What is the difference between @@Error and @@Rowcount ?
Q 306 What is a Service Broker in SQL?
Q 307 What is Database Mirroring in SQL?
Q 308 What is Extended Stored Procedure in SQL?
Q 310 What is an Execution Plans in SQL?
Q 311 >What is Dead Lock?
Q 312 What is an example of Deadlock?
Q 313 How to Resolve Deadlock?
Q 314 What is Live Lock?
Q 315 What is an example of Live Lock?
Q 316 What are the options available to Move Database between servers?
Q 317 What is Replication?
Q 318 What is Union?
Q 319 What is Union ALL?
Q 320 List some of the DBCC (Database Console Commands for SQL Server) Commands?
Q 321 >What is a Full Database Backup type in SQL?
Q 322 What is a Differential Database Backup type in SQL?
Q 323 What is a Transactional Log Database Backup type in SQL?
Q 324 What is a Log Database Backup type in SQL?
Q 325 What are the advantages of NoLock in SQL?
Q 326 What are the disadvantages of NoLock in SQL?
Q 327 What is GRANT command in SQL?
Q 328 What is REVOKE command in SQL?
Q 329 What is Privileges command in SQL?
Q 330 What is Cascade command in SQL?
Q 331 >What is the use of RESTRICT Keyword in SQL?
Q 332 What is the use of DML in SQL?
Q 333 What is the use of DDL in SQL?
Q 334 What is the use of DCL in SQL?
Q 335 What is the use of TCL in SQL?
Q 336 What is the use of Wildcards in SQL?
Q 337 What is the use of Aggregate functions?
Q 338 What is the use of ROLLUP in SQL?
Q 339 What is the use of CUBE in SQL?
Q 340 What are the Differences between CUBE and ROLLUP?
Q 341 >What is the use of CUBE Operator in SQL?
Q 342 What is the Difference between ROLLUP and COMPUTE?
Q 343 What is the use of COMPUTE in SQL?
Q 344 What is the use of COMPUTE BY in SQL?
Q 345 What is the use of With TIES in SQL?
Q 346 What is the use of ALL & ANY operator in SQL?
Q 347 What is the use of Master Database in SQL?
Q 348 What is the use of MSDB Database in SQL?
Q 349 What is the use of TEMPDB Database in SQL?
Q 350 What is the use of MODEL Database in SQL