You are on page 1of 87

Polaris Sample Question Papers -2010 1. What is State Management in dotnet. 2. State management in webservices. 3.

Ways to secure a web service 4. Project Discussion 5. What are delegates 6. Communication between 2 usercontrols in a same webpage 7. Jquery for Implementing Ajax 8. ICallbackEventHandler Interface 9. Oops Concepts & multithreading. 10.Difference between Interface and Abstract class(Very deeply). 11.Difference between Functions and a Stored Procedures 12. Design patterns 13. Describe Db creation process. 14. View in db, diff between view& materialized view. 15. Ajax & exception handling in dotnet & oracle. 16. how are u handling team. 17. If u feel that 1 guy is struggling in your team, how will u manage. 18. What are the suggstions for performance tunning in oracle. 19. Advantage of using packages in oracle. 20. Clustered & non Clustered Indexes . 21. how to reduce bulkiness in oracle. 22. Events in data grid. 23. what do we use indexes. 24. C# befints. 25. collections in dotnet. 26. Varray in oracle. 27. Diff between sub & corelated subquery. 28. Types of joins. 29. Diff in delete & truncate. 30. Find duplicates in oracle. 31. Use analytical functions. 32. There are 5 tales, how many joins will be there.

1. What is Endpoints Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint. 2. What is three major points in WCF? 1) Address --- Specifies the location of the service which will be like http://Myserver/MyService.Clients will use this location to communicate with our service. 2)Contract --- Specifies the interface between client and the server.It's a simple

interface with some attribute. 3)Binding --- Specifies how the two paries will communicate in term of transport and encoding and protocols.

3. Hosting types in WCF 1. IIS 2. Self Hosting 3. WAS (Windows Activation Service)

4. Difference between Web Service and WCF Web Services


1.It Can be accessed only over HTTP 2.It works in stateless environment

WCF WCF is flexible because its services can be hosted in different types of applications. The following lists several common scenarios for hosting WCF services:

IIS WAS Self-hosting Managed Windows Service

Explain contracts in WCF

6. What is WCF Session: It is different than HttpSessions which is used to stroe HTTPRequest.more 7. What is it the Net.TCP Port Sharing? How can we use it? 8. Enumerate three message exchange patterns in the WCF model. 9. How you can handle exception in WCF

10. How to enable streaming? 11. How to Implement Security in WCF Services and how it is different from Web Service.

Explain the Asp.net Page Life Cycle What is bubble event and how it work's How to use scalar, in case of multiple tables what will be the output. If Master Page is attached with a child, which event's will be fired first. Explain the execution of page. How to get the source of calling page Difference Between Response.redirect & Response.Transfer Explain the use of Request.UrlReferrer Difference Between Abstract Class and Interface Difference Between HttpWebRequest and Response.write Explain Early binding. What is UserControl, difference between usercontrol and custom control

What is Join(Left, Right, Full) Difference between Unique and Unique All in SQL Server Can we have more than 1 Cluster Index in Any version of SQL Server? Can we use Trigger with Truncate command? Can we user transactions in Triggers? What is Normalization What is difference between Not in & Minus Clause Can we use multiple table in from clause with Update statement in SQL Server and Oracle. When to use Exist clause in SQL what are the oops concept ? What is code access Security ? Why CLR is Important and how it's work. How Dot net interact with com component ? Explain the Page life cycle of Asp.net what is inheritance ? what are delegates how you use it ? what are normalization ? what is data reader ? what is difference between data table copy and clone ? what is the use identity column in SQL Server? What is Execute Scalar? How you can handle exception in Sql server? Can we you try catch block in SQL server? How many cluster indexes we can have? what are constructor can we create private constructor ?

What is the syntax to find the nth highest salary of the table. Tell me the Architecture of your project. Cookies are very popular in Web development, and used to store visitors data. They Provide another way to store information of web page for later use. Mainly it is used to remember users between visits. You can retain the values of web page during the postbacks and can use the same value in any page of your web application. It is a very small text file and stored in the client machine, but is easily traceable. It has so many limitations #1. User can not store data more than 4096 KB #2. User can easily stops/disable cookies by browser We can use cookies in asp.net by using collections. Sample Code
//How to Add void Cookies_Add() { HttpCookie LanguageCookies = new HttpCookie("LanguageCookies"); LanguageCookies.Value = "English"; LanguageCookies.Expires = DateTime.Now.AddMinutes(20); Response.Cookies.Add(LanguageCookies); } //How to Read void Cookies_Read() { string str = Request.Cookies["LanguageCookies"].Value; } //How to delete void Cookies_Delete() { if(Request.Cookies["LanguageCookies"]!=null) { // cookies will be expiry immediatly Response.Cookies["LanguageCookies"].Expires = DateTime.Now.AddMinutes(-1); } }

Interview was very cool, and the interviewer's knowledge was also up to the mark. was a normal interview, they started with personal details for example tell me something about your self, why are you looking for change, what is your roles & responsibility. Then they started technical stuff as below

What is Garbage collector Explain the Generations in Garbage collection Difference Between Finalize & Dispose Method. What is Suppress Finalize What is Difference between Value Type & Reference Type String is a value type or reference type What do you understand by Stack What is View State What is Singleton Class What is abstract class

How to print a string in reverse order How you can create a class as singleton Explain the 3 Normalization rules Let's say you have have to create the order-details forms, how many tables do you required. What is Lembda expression and tell me the scenario when you can implement

You have a SQL Server 2005 cluster and need to add anti-virus software as per your corporate standards. What should you exclude from scans?

Log and data files for your databases as well as the Quorum drive and the backup folders. Anti-virus programs can exist on the same server as SQL Server without an issue if you exclude certain items. The database data and log files, backup files and folders, the quorum drive for clusters, temporary replication files, the SQL Server log files, and Log Shipping folders/files. You do not need to exclude that SQL Server executables and probably do not want to so that they are protected. Questions to ask a SQL Server database developer applicant
Can you give me an overview of some of the database objects available for use in SQL Server 2000?

You are looking for objects such as: tables, views, user-defined functions, and stored procedures; it's even better if they mention additional objects such as triggers. It's not a good sign if an applicant cannot answer this basic question.
What is an index? What types of indexes are available in SQL Server 2000?

Any experienced database developer should be able to answer this question with ease. Some of the less-experienced developers will be able to answer it, but with a little less clarity. Weekly SQL tips in your inbox TechRepublic's free SQL Server newsletter, delivered each Tuesday, contains hands-on tips that will help you become more adept with this powerful relational database management system. Automatically sign up today! In its most simple terms, an index is a data structure used to provide quick access to data in a database table or view. In SQL Server, they come in two flavors: clustered and nonclustered. Clustered indexes store the data at the leaf level of the index. This means that whichever field(s) in your table are included in the clustered index, they will be stored in an orderly fashion in the table. Because of this sorting, you can only have one clustered index per table. Non-clustered indexes contain a row identifier at the leaf level of the index. This row identifier is a pointer to a location of the data on the disk. This allows you to have more than one non-clustered index per table.
What does NULL mean?

The value NULL is a very tricky subject in the database world, so don't be surprised if several applicants trip up on this question. The value NULL means UNKNOWN; it does not mean '' (empty string). Assuming

ANSI_NULLS are on in your SQL Server database, which they are by default, any comparison to the value NULL will yield the value NULL. You cannot compare any value with an UNKNOWN value and logically expect to get an answer. You must use the IS NULL operator instead.
What is a primary key? What is a foreign key?

A primary key is the field(s) in a table that uniquely defines the row in the table; the values in the primary key are always unique. A foreign key is a constraint that establishes a relationship between two tables. This relationship typically involves the primary key field(s) from one table with an adjoining set of field(s) in another table (although it could be the same table). The adjoining field(s) is the foreign key.
What are triggers? What are the different types of triggers in SQL Server 2000?

It's very beneficial for a potential database developer to know the types of triggers available, and how to implement them.

A trigger is a specialized type of stored procedure that is bound to a table or view in SQL Server 2000. In SQL Server 2000, there are INSTEAD-OF triggers and AFTER triggers. INSTEAD-OF triggers are procedures that execute in place of a Data Manipulation Language (DML) statement on a table. For example, if I have an INSTEAD-OF-UPDATE trigger on TableA, and I execute an update statement on that table, the code in the INSTEAD-OF-UPDATE trigger will execute instead of the update statement that I executed. An AFTER trigger executes after a DML statement has taken place in the database. These types of triggers are very handy for auditing data changes that have occurred in your database tables.
How can you ensure that a table named TableB with a field named Fld1 will only have those values in the Fld1 field that are also in the table named TableA with a field named Fld1?

This relationship related question has two potential answers. The first answer (and the one that you want to hear) is the use of foreign key constraints. A foreign key constraint is used to maintain referential integrity. It is used to ensure that a field in a table will only hold values that are already defined in another field in a different (or the same) table. That field is the candidate key (usually a primary key of the other table). The other option is the use of triggers. Triggers can be used to ensure the same effect of constraints in a roundabout way, but it is much more difficult to set up and maintain, and the performance is typically worse. Because of this, Microsoft recommends that developers use foreign key constraints instead of triggers for maintaining referential integrity.
What is a performance consideration of having too many indexes on a production online transaction processing (OLTP) table?

You are looking for the applicant to make some reference regarding data manipulations. The more indexes on a table, the more time it takes for the database engine to update, insert, or delete data, as the indexes all have to be maintained as the data manipulation occurs.
What can be used to ensure that a field in a table only accepts a certain range of values?

This question can be answered a couple of different ways, but only one answer is a "good" one. The answer you want to hear is a Check constraint, which is defined on a database table that limits the values entered into that column. These constraints are relatively easy to create, and they are the recommended type for enforcing domain integrity in SQL Server. Triggers can also be used to restrict the values accepted in a field in a database table, but this solution requires the trigger to be defined on the table, which can hinder performance in certain situations. For this reason, Microsoft recommends Check constraints over all other methods for restricting domain integrity.
What is the difference between a return parameter and an OUTPUT parameter?

If the applicant is able to answer this question correctly, the odds are good that they have some experience working with stored procedures. A return parameter is always returned by a stored procedure, and it is meant to indicate the success or failure of the stored procedure. The return parameter is always an INT data type. An OUTPUT parameter is designated specifically by the developer, and it can return other types of data, such as characters and numeric values. (There are some limitations on the data types that can be used as output parameters.) You can use multiple OUTPUT parameters in a stored procedure, whereas you can only use one return parameter.
What is a correlated sub-query? How can these queries be useful?

The more seasoned developer will be able to accurately describe this type of query. A correlated sub-query is a special type of query containing a sub-query. The sub-query contained in the query actually requests values from the outside query, creating a situation similar to a loop. You can find a more detailed description as to how these special types of queries work in this article.
What level of permissions does a user need to create an assembly with UNSAFE permissions?

sysadmin Only a sysadmin can create assemblies that are specified as unsafe.

Which optional SQL Server component must you install to ensure that you can create and execute maintenance plans?

SQL Server Integration Services You must install Integration Services in order to properly create and execute maintance plans since these plans are a subset of SSIS packages.
You have tightly secured access to your SQL Server 2005 server by placing it behind a firewall and limited ports 1433 to those clients that need to directly access the SQL Server. One of your developers complains about connecting to the Integration Services esrvice on your server. What could be the problem if you know the service is working properly?

The firewall needs to allow port 135 through for Integration Services Integration Services requires access to both DCOM and port 135. You need to open this port to allow the developer to communicate with SSIS.
In SQL Server 2005, which network protocols use endpoints?

All of the above

All communication points with SQL Server using network protocols use an endpoint. SQL Server creates defaults for each protocol that you enable.
You have a SQL Server 2005 cluster and need to add anti-virus software as per your corporate standards. What should you exclude from scans?

Log and data files for your databases as well as the Quorum drive and the backup folders. Anti-virus programs can exist on the same server as SQL Server without an issue if you exclude certain items. The database data and log files, backup files and folders, the quorum drive for clusters, temporary replication files, the SQL Server log files, and Log Shipping folders/files. You do not need to exclude that SQL Server executables and probably do not want to so that they are protected.
What port do you need to open on your server firewall to enable named pipes connections?

Port 445 Named pipes communicates across TCP port 445.

When the network service built-in account connects to a network resource, what is the context?

The computer account of the Windows installation. The network service account connects to network resources as the computer account for the Windows installation.
A certificate is like which type of key in SQL Server 2005 encryption?

An Asymmetric Key A certificate is like an asymmetric key and can validate the identity of the issuer.
How many connections are available in SQL Server MSDE 2000?

Unlimited, no different from the other SQL Server 2000 editions. The answer is actually an unlimited number of connections, though this in a practical sense is limited by memory on the machine (The actual limitation is 32k connecitons). Instead there is a governer that kicks in to limit things to 8 operations, of which 3 are system operations in some cases. But these are operations, not connections.
What will be the result of the last SELECT statement if you execute the T-SQL script below as a sysadmin.

USE master GO IF DB_ID('test_schema') IS NOT NULL DROP DATABASE test_schema GO CREATE DATABASE test_schema GO USE test_schema GO CREATE SCHEMA Schema1 CREATE TABLE Table1 (col1 int) GO CREATE SCHEMA Schema2 GO CREATE TABLE Table1 (col1 int)

GO SELECT SCHEMA_NAME(schema_id), name FROM sys.objects WHERE name = 'Table1' Schema1 Table1 dbo Table1 The correct answer is A. You can combine the CREATE SCHEMA with a CREATE TABLE. You can even specify GRANTs or DENYs. Search Books online for CREATE SCHEMA.
You are considering consolidating a number of your existing SQL Servers onto a new, large SQL Server 2005 server. You have 3 SQL Server 6.5 servers, 6 SQL Server 7.0 servers, and 16 SQL Server 2005 servers. You cannot make any application changes, but you can size a large SQL Server 2005 server to handle the disk, memory, and CPU needs of the existing servers as well as set compatibility modes. How many of these servers can you consolidate?

25 In SQL Server 2005, you can handle a large number of transactions, which makes it a good choice for consolidating servers. It includes compatibility modes for SQL Server 6, 6.5, 7 and 2000. Therefore you can consolidate all the servers, 25 of them, onto the new server.

To maintain the best performance of your SQL Server 2005 databases, how should you deploy encryption technologies?

Encrypt data with a symmetric key and secure all keys with asymmetric keys. For performance reasons, you should encrypt data using a symmetric key and secure that key with an asymmetric key.
In SQL Server 2005, which network protocols use endpoints?

All of the above All communication points with SQL Server using network protocols use an endpoint. SQL Server creates defaults for each protocol that you enable.
In SQL Server 2005, can you include a user-defined role as a member of another user-defined role?

Yes Yes you can.

In SQL Server 2005, what does instance aware mean for a service?

The service is installed once for each instances on the server. An instance aware service is one that is installed for each instance on the server. An instance-unaware service is only installed once , no matter how many instances. Integration Services is instance-unaware whereas SQL Agent is instance aware.
If you use the EXECUTE AS clause to impersonate a user at a database-scoped level. Can you execute a query through a linked server if the impersonated user has the rights to do so when normally logged in? No trust relationships exist between the databases.

No If you change your execution context to a user, which is scoped at a database level, then any queries to linked servers or other databases will fail. There is a way around this restriction if trust relationships are setup.

The nesting level for stored procedures in SQL Server 2005, but how many databases can you access inside one stored procedure? 8 The footnote for nested stored procedures limits the number at 8.
Is it possible to build an index on a view ?

Yes Yes, an index can be put on a view but the first index must be a unique clustered index.
What does REVERT do in SQL Server 2005?

Restores your previous execution context. If you have changed your execution context with EXECUTE AS, the REVERT statement will restore the last context prior to the EXECUTE AS.
What does SEND do in SQL Server 2005?

Sends a service broker message using a conversation. SEND is used to send a message on an existing conversation in the Service Broker architecture.
In SQL Server 2005, most data for your data types is stored in the pages for the table. Binary objects, such as image or text, are stored in LOB or large Object data pages. Where is varchar(max) data stored?

In LOB pages Since the size restrictions for varchar(max) are the same as for text data, this data is stored in LOB data pages.

What will occur with the following code in SQL Server 2005 if executed by Alice?

execute as user = 'Bob' with no revert select user_name() go revert select user_name() go You will receive as results: bob An error The NO REVERT option with EXECUTE AS prevents the return of execution context to the previous value. If you run the REVERT statement, you will receive the following error:
You have to create some T-SQL that produces an order of players in a golf tournament. Players who finish on the same number of strokes have to be given the same finishing place denoting that they will have an equal prize amount. What T-SQL function can achieve this?

RANK alongside the OVER function where the OVER function uses the players number of strokes taken The rank function will return the rank of the row in the result set. Ties will receive the same rank. The OVER clause will separate out the ranking into partitions and use those for calculating the proper placement of the golfers.

You want to disable the trigger dEmployee on the HumanResources.Employee table in the SQL Server 2005 AdventureWorks sample database. Which of the following statements will do the trick? Answer A and B Explanation Either of the commands in A and B will disable the trigger. In SQL Server 2005, if you want the keys securing your data to expire over time, what type of key encryption would you choose? Answer Certificates Explanation Certificates have an expiration data associated with them. This allows you to issue them to users and force a reissue in order to maintain their access to data. Which is larger in size in SQL Server 2005 if you are using symmetric keys? Answer Ciphertext Explanation Ciphertext is larger and can be calculated using the following formula: Size = ( FLOOR (8 + D)/BLOCK) + 1) * (BLOCK + BLOCK + 16) where D is the data size in bytes, BLOCK is the block size (8 or 16, depending on algorithm) and Size is the new size in bytes of the ciphertext.
What result would you expect from this statement?

Select * from dbo .MyTable

All records from [dbo].[MyTable] The answer is all records from [dbo].[MyTable]. Qualified names can include white space before and after the dots. Restrictions apply only to the names themselves that may need quoted identifiers with embedded white space or invalid characters.
You are using SQL Server 2005 and you wish to find a number of details about stored procedures created. The details include date and time, the server that created the stored procedure, the login name and the contents. How would you do this?

Create a DDL trigger on CREATE_PROCEDURE database event The answer is Create a DDL trigger on CREATE_PROCEDURE database event You can find the answer on page 448 of Beginning SQL Server 2005 for Developers: From Novice to Professional

A .NET assembly running with UNSAFE permissions can do which of the following?

All of the above CLR code running with UNSAFE permissions can access virtually any resource inside or outside of SQL Server without restriction. This is one reason only a sysadmin can create an assembly as UNSAFE.
What does the SQL Writer service do?

Handles Volume Shadow Service Copy functions. The SQL Writer service was introduced to handle access to the data files in SQL Server. It allows backup programs, like VSS, to function while SQL Server is still running.
Which key provides the strongest encryption?

AES (256 bit) The longer the key, the better the encryption, so choose longer keys for more encryption. However there is a larger performance penalty for longer keys. DES is a relatively old and weaker algorithm than AES.
You are delegating permissions on your SQL Server 2005 server to other administrators. You have local, single server jobs on one server that you would like to allow another administer to start, stop, and view the history for, but not delete history. This administrator will own the jobs. Which role should you assign?

SQLAgentUserRole SQL Server 2005 provides 3 fixed roles for the agent service that limit privileges for administrators. The SQLAgentUserRole is designed for local jobs (not multiserver) that allows the member to work with their owned jobs (edit, start, stop, view history) without deleting the history of any job.
What does this return?

SELECT USER_NAME() -- Returns Andy EXECUTE AS TechPreparation GO EXECUTE AS Steve GO REVERT GO SELECT USER_NAME() TechPreparation The execution context switches can be nested, so changing to TechPreparation, then Steve, then issuing a Revert will return you to the context of TechPreparation. This works in the same manner as a stack.
In building a PDF report in Reporting Services 2005, images that are originally stored in jpg format are rendered in jpg format. What format are images rendered in if they were stored originally in another format?

png Images stored originally in formats other than jpg are rendered in png format.
What does the tablediff utility do?

This utility will report the differences in data between two tables. This utility will report the data differences between two tables. They must be alike in

structure and give back the T-SQL to bring the data in the tables to be the same for most datatypes.
Which severity levels of errors can be corrected by a user (as opposed to those that an administrator or Microsoft must work to fix.)

11-16 Severity levels 11-16 are correctable by users. Below 11, these are informational warnings and not raised as system errors. Errors above 16 must have an administrator or Microsoft correct.
What is the granularity in seconds of the timestamp datatype?

The timestamp datatype does not store time values. The answer is the timestamp datatype does not store time values. The better name for this datatype is rowversion, and it is actually a database-wide unique varbinary value. When you have a rowversion column in a table, the value of the rowversion column changes for each modification to each row. The value in the rowversion column is guaranteed to be unique across all tables in the datatype.
You are setting up the backup scheme for your SQL Server 2005 server and want to setup nightly full backups and hourly log backups in the Maintenance Plans subsystem. How many plans must you setup?

2 Since you have two separate schedules for the maintenance operations, you will need to have two separate plans to handle this need. Each plan can only be executed on one schedule, so one is needed for a single daily execution, the nightly full backups, and another for the hourly log backups.

You have installed one new assembly on your SQL Server 2005 server and are wondering if it is being used on the production server. How can you easily monitor to see if this assembly is being used?

You can monitor the Assembly Load event in a trace. While you could scan trace results for the names of functions and procedures using the assembly, it is possible that you may not know all the places the assembly is being called from. There is a CLR Load event class that will capture an event when a CLR class is executed.
You wish to ensure you can recover your SQL Server 2005 database to a point in time if necessary. Which recovery models can you use?

Full Only the Full recovery model supports point in time restoration of your database.

Does a root element in an XML document necessarily contain all the content for a well-formed document?

Yes By definition, the root element is required in a well-formed XML document and it contains all other content nested inside it.
Which of the following datatypes can be represented in a SQL_VARIANT datatype?

None of the above. The SQL Variant type can store all datatypes except varchar(max), varbinary(max), xml,

text, ntext, rowversion/timestamp (thought the data of a rowversion can be stored in a binary(8), which can be stored in a sql_variant) and sql_variant (it may seem strange that you cant store a variant in a variant, but all this is saying is that the sql_variant data type doesnt actually exist as suchSQL Server chooses the best type of storage to store the value you give to it).
What's the difference between a server login and a database user?

A server login connects an account to the server. A database user the link from the server login to a defined database . You need to create a server login using CREATE LOGIN before you can then link it to a database using a database user with CREATE USER. The server login logs into the server and grants access to any server wide permissions. The server login is then mapped to a database user for access to database objects.
For regulatory reasons, you must maintain an exact text copy of your XML documents in your SQL Server 2005 database. What datatype of storage should you choose?

varchar(max) The XML data type changes the representation of your XML document into an internal, optimized version that has all the content, but may not maintain the original text. The varchar(max) or nvarchar(max) represenations should be used in this case.
What is a bookmark lookup?

An operation where the row in the heap or clustered index is found from the bookmark in the index. A bookmark ID is stored in an index and points back to the actual row in the heap or clustered index of the table. The lookup operation occurs when an index satisfies a search and the actual row is retrieved from the table.
Yesterday's QOD How are comments denoted in an XML document?

With the <!-- and --> markers. Comments in an XML document are denoted just as they are in HTML with the markers.
How secure are encrypted stored procedures, triggers and views?

They are not really secure, that are only obfusticated. There are tools that you can use to get at the code. The code itself is just obfusticated. However, you cannot edit the code, the stored procedure or view would have to be dropped and re-created. By combing this fact with a DDL trigger that executes on object creation you can tell when it has been modified.
You have created a new assembly and want to test it on SQL Server 2005. You install the developer edition with defaults on your workstation and create the assembly as a sysadmin. You then write a function to use this assembly, but it does not work. What could be the problem?

The CLR environment needs to be enabled. By default on SQL Server 2005, the CLR runtime environment, which is what executes the .NET assemblies, is not enabled. You need to execute the following code to enable it:
The Service Broker operates on messages in which fashion?

Like a queue, first in, first out.

Messages transferred in Service Broker work in a queue fashion with the first message being sent being the first processed.
You have a user that agrees to take over some of the database administration for your SQL Server 2005. They will be in charge of granting access to one particular database used by the time card application for server logins. What security role should you assign them?

db_accessadmin This user will not add logins, but rather grant database level access for existing logins, therefore the minimum role they need is the db_accessadmin fixed database role. This allows them the ability to add access for Windows logins, Windows group logins, or SQL Server logins.
What does this method in SQL Server 2005's SMO equate to in T-SQL? db.CheckTables(RepairType.None)

DBCC CHECKDB WITH NO_INFOMSGS This SMO method executes a DBCC CHECKDB with the NO_INFOMSGS option set.
In replication, what is each set of the source data that is replicated from the source server called?

Article Each set of source data that is replicated is called an article.

In SSIS, what is the difference between output columns and external columns?

External columns represent the meta data of external data sources and output columns are used be data flow source adapters. Output columns are used by all data-flow source adapters and transformations. They are not used by destination adapters. Put simply, they represent the metadata of the data flowing out of the component. External columns represent the metadata of external data sources and destinations. As such, only source & destination adapters have external columns because these are the only components whose buffered pipeline data interacts with these external sources and destinations.
You want to be sure your database server if properly secured. You have two instances, a default instance and a named instance installed. Which ports do you need to open?

1433 and a specific port after configuring the named instance to use that specific port Named instances must be configured to use a specific port and that port then opened in the firewall.

You have a relatively new SQL Server 2005 and msdb is corrupt. How can you fix this database without a restore? (data loss is acceptable)

Stop the server and restart it with a trace flag to allow system databases to be detached. Then copy a new version from the /INSTALL folder. By starting SQL Server with trace flag 3608 you can detach the msdb database. You can copy a new initial version from the installation CD.
In SQL Server 2005 Integration Services, if you want to import a flat file very quickly that contains only integer data, what type of parsing should you use?

Fast Parse

The fast parse mode that is set on columns for a flat file source connection can import a limited set of data types extremely quickly.
In a new default SQL Server 2005 installation, what is the status of the dedicated administrator connection?

Enabled for local connections only. The dedicated adminstrator connection is enabled for local connections only by default.
In the REPEATABLE READ isolation level, what phenomena is still possible?

Phantom rows The answer is Phantoms rows. A phantom row refers to the situation where you execute a DML statement that retrieves data, and another process may add new rows the result set. For example: SET ISOLATION LEVEL REPEATABLE READ BEGIN TRANSACTION SELECT * FROM table We return the following rows: ColumnName ----------row1 row2 You are guaranteed to get back at least these rows, and no other user may delete these rows (the rows are locked with a shared lock) This is what is referred to as a repeatable read. However, a user might add another row: SELECT * FROM table ColumnName ----------row1 row2 row3 To prevent phantoms, use the SERIALIZABLE isolation level.
You are designing a new server that will hold 2 instances of SQL Server 2005 in a consolidation project. One of the existing servers has 4GB of RAM and the other has 2GB. You do not want either instance to feel memory pressure, so you specify a new server with 8GB of RAM. What else should you configure on these instances?

Min and Max memory for each instance If you are designing multiple instances, you will want to specify the amount of RAM that each has access to. If you do not do this, performance can vary dramatically as the servers compete for memory.
You have specified that a SQL Server 2005 login must respect the password policy on a Windows XP host. Which of the following are valid passwords for the user Kendall?

All of the above are valid On a Windows XP host, the password policy is not enforced because the appropriate API call is not available on the operating system.

A certificate is which type of security mechanism?

Asymmetric Key A certificate is an asymmetric key that provides encryption in addition to authentication of an entity.
Which of the following services is instance-aware?

Analysis Services Of these, only Analysis services is instance-aware.


What What does the term ACID refer to?

An acronym that describes concurrency support in a database The answer is an acronym that describes concurrency support in a database. ACID is an acronym for the following four terms: * Atomicity - Every operation within a transaction is treated as a singular operation; either all of its data modifications are performed, or none of them is performed. * Consistency - Once the transaction is completed, the system must be left in a consistent state. * Isolation - It means that the operations within a transaction must be suitably isolated from other transactions. In other words, no other transactions should see data in the intermediate state, within the transaction, until it is finalized. This is done by using locks. * Durability - Once a transaction is competed, all changes must be persisted as requested. The modifications should persist in total even in the event of a system failure.
To recover an instance of Notification Services in 2005 on another server, what information would you need?

A backup of the database holding Notification Services and the XSD and XSLT files as well as the name and password for the service account. To recover SSNS, you need the database backup as well as the operational files, XSD and XSLT files, stored on the file system and the account information used for the service account. Since SSNS usually works with data outside of the SQL Server, a domain account is usually used to ensure proper permissions.
What type of connectivity does the readpipe/makepipe utility test?

Named Pipes The readpipe and makepipe utility combination will test named pipe connectivity.
In SQL Server 2005, which of the following schema changes are supported for the publication objects of a replicated database?

All of the above. SQL Server 2005 replicated databases support the following schema changes for objects: * ALTER TABLE * ALTER VIEW * ALTER PROCEDURE * ALTER FUNCTION * ALTER TRIGGER (DML only)
You want to disable the receipt of messages in one of your databases by the Service Broken. How should you do this?

ALTER DATABASE Sales SET DISABLE_BROKER To disable the receipt of messages, you can disable the Service Broker by disabling it with the ALTER DATABASE command. The SET command is "DISABLE_BROKER".

You are building a .NET assembly that will access the registry of the local machine for a factor used in a computer column. What permission set should you assign it?

EXTERNAL_ACCESS The most restrictive permission set should always be used for .NET assemblies in keeping with a secure SQL Server environment. Only the EXTERNAL_ACCESS and UNSAFE permission sets will allow registry access and UNSAFE permissions are not required.
You are developing security policy for your SQL Servers and have all of the data entry clerks needing access to a series of tables. You create a Data Entry role and assign the proper permissions as well as add the users. You then find out that Bob is a part of the HR group because of cross training and needs to use the same objects from the same application except for the Vacation table, to which he should not have access. No column permissions are assigned. What should you do?

Create an new role and DENY permission to the Vacation table for this role. Add Bob to this role. To effectively handle security, you want to minimize the administrative burden. Bob is a member of the Data Entry role, and because of cross training, you do not want to remove him from this role, but you do need to DENY permission to the Vacation table. The best way to do this is with another role specifically to DENY this permission.
You are trying to track down issues with a SQL Server 2005 application using Profiler. The part of the application you are checking uses the EXECUTE AS statement to change the context of every user to the user Bob. How can you determine which user is executing statements in Profiler?

Check the Sessionloginname data column. The SESSIONLOGINNAME column, not shown by default, will contain the original login name of the user even if their context has changed in the application.
Assuming the column name is correct, which of the following is a valid cast operation in SSIS _expression language?

(DT_STR, 20, 1252)[MyColumn] The correct answer is (DT_STR, 20, 1252)[MyColumn]. The cast uses parens and then the cast type specification with the _expression to be converted afterwards.
There are two types of subscriptions in SQL Server replication. What are they?

Push/Pull The two types of subscriptions are push and pull.

What is the scope of the control permission in SQL Server 2005?

It allows the grantee the equivalent of ownership in that they have all permissions and can grant them to others. The Control permission is equivalent to assigning ownership of the securables. All available permissions are granted to the principal, and they the principal in turn can grant those permissions to others.
When testing connectivity in SQL Server, you use which utility in conjunction with the readpipe utility to establish a connection?

makepipe The makepipe utility is used with the readpipe utility to test connectivity only for named pipes connections. This utility has been deprecated in SQL Server 2005.

In SQL Server 2005, you want to monitor your transactional replication and determine how long it takes for a transaction to move from the publisher to a subscriber. What would you use to help you do this?

Tracer Tokens. You can use tracer tokens in SQL Server 2005 replication to measure latencies. These are small amounts of data written into your transaction logs.
How many credentials can one login be mapped to?

1 A credential can be mapped to many logins, but a login can only be mapped to one credential.
You are looking to secure your publisher to prevent unauthorized logins from accessing the data through replication. Where do you add the list of logins that have access?

Add them to the Publication Access List in the publication database. All access to publications is controlled with the Publication Access List (PAL), which is similar to the Windows ACLs. A list is created for each publication that is set up.
What does the ERROR_PROCEDURE() function return?

The name of the stored procedure that caused an error. The ERROR_PROCEDURE() function is placed in the catch block of a TRY..CATCH construct and returns the name of the procedure that caused an error to be thrown.
Credentials in SQL Server 2005 are used to access what?

Resources outside the SQL Server A credential is used to access resources outside of SQL Server. It contains the authentication information needed for accessing these resources.
Which of the following is an invalid file name for a database file?

None of the above Explanation from BOL: SQL Server 2005 does not enforce the .mdf, .ndf, and .ldf file name extensions, but these extensions help you identify the different kinds of files and their use.
What does @@options return?

The current SET options for the connection. The @@options variable returns a list of the options set for the current connection. This is returned as integer and each bit in the integer represents an option.
You have setup forwarding for your SQL Server 2005 Service Broker queues to another server. You edit a route to move a queue to a new server. What do you need to do now to ensure you can recover the routes in the event of a disaster?

Back up the msdb database. The routes for forwarding are stored in msdb.sys.routes. If you back up the msdb database, the routes will be captured.

You are looking to setup a large Notification Services application and you are planning on a 40GB database. When installing Notification Services, the creation fails. What is the likely problem?

Notification Services installation has a 10 minute timeout and the database creation

probably took longer than that. The Notification Services timeout for database creation is 10 minutes. If the database takes longer to create, the installation of the instance fails. You need to reduce the size of the database for installation and then increase it when you are done.
You have enabled AWE for your SQL Server 2005 server and allocated 4GB or RAM on one of your servers. An ASP.NET application on the same server is feeling memory pressure and you want to release some memory and reduce SQL Server to 3GB or RAM. How can you do this?

Change the max amount of memory allocated and shut down and restart SQL Server to have it take affect. Once memory is allocated through AWE, it cannot be released unless the SQL Server is restarted.

You are troubleshooting a Service Broker application and find that messages are remaining on the queue. You determine that there is no active queue monitor. What should you do?

Use the ALTER QUEUE statement to turn activation on. One of the troubleshooting steps if messages remain in the queue is to check for an active queue monitor. If one is not on, then it needs to be activated. The ALTER QUEUE statement is used to change this.
You are implementing replication across the Internet for a large bank that wishes to move up to date pricing information to an analyst's laptop. They are concerned about spoofing of their main site by criminals. What can you do to secure the replication solution with SQL Server 2005?

Set the encryption level to verify the certificate is issued by a trusted authority. Since you are asked to use replication, a replication solution is to use encryption for the connection and verify the certificate being used is from a trusted authority. Setting the encrpytion level to 2 will do this.
In SQL Server 2005, you are looking to implement full-text search. One of the tables you are looking to index stores Mircrosoft Word documents in a varbinary(max) column. Can you use Full-text search to index this column?

Yes You can use full-text search for formatted data such as Word that contains text stored in a varbinary column.
You wish to configure event logging for your SQL Server 2005 Notification Services instance. Where would you make this change?

Edit the nsservice.exe.config file in the C:\Program Files\Microsoft SQL Server\90\NotificationServices\n.n.nnn\bin folder. Event logging and most Notification Services configuration require editing an XML file. In this case, the NSservice.exe.config file is edited to set the appropriate editing level.

Which of the following is not true about the Raw File Destintion connection in SQL Server 2005 Integration Services?

It supports BLOB object data. The Raw File Destination connection does not use a connection manager, supports NULL data, and only has one input. It also does not support BLOB data or have an error output.

What message types exist in SQL Server 2005 Service Broker?

These are defined for each contract. Each application that sets up queues and contracts inside Service Broker must define the message types that are valid for the contract.
What does the CEILING() function do?

Returns the smallest integer greater than or equal to the value passed in. CEILING() returns the smallest integer that is great than or equal to the value passed in.
What is a dialog conversation in the SQL Server 2005 Service Broker.

A dialog conversation is a conversation between services. A dialog conversation is a conversation between services. A conversation includes messages being passed back and forth as part of a contract.
What is row versioning in SQL Server 2005?

Row versioning keeps a copy of each row for use by applications or transactions to prevent readers from being blocked by writers. Row versioning is a method whereby the database engine keeps a copy of a row's data as it existed before the start of a transaction for queries to read this data and reduce locking contention if they are configured.
What does @@MAX_PRECISION return?

The maximum precision for numeric and decimal data. This function returns the maximum precision for numeric and decimal data as set on the server. The default for SQL Server 2005 is 38.
Which of the following columns can be indexed with SQL Server 2005 Full-Text Search?

char, varchar, nvarchar, and varbinary, text, ntext, and image All character columns, char, varchar and nvarchar columns including max, text and ntext, and image columns are valid for full-text searching.
When starting SQL Server 2005 from the command line, what does the -h switch do?

This switch reserves memory space for Hot-Add memory metadata, available with AWE enabled. This switch is used with 32-bit SQL Server and AWE to reserve memory to reserve memory space for Hot-Add memory metadata.
Janice has two tables, Employees and Orders. She has been asked to provide a report of the number of orders processed by each employee in the month of June. If an employee didnt process any orders, the report should reflect the employees name and a zero for the number of orders. Which of the queries is the best one for Janice to use to return the information she has been requested to provide?

SELECT E.LastName + ', ' + E.FirstName AS [Employee Name] , ISNULL(O.[# of Orders], 0) [# of Orders] FROM dbo.Employees E LEFT JOIN (SELECT EmployeeID , COUNT(*) [# of Orders]

FROM dbo.Orders WHERE OrderDate >= '20060601' AND OrderDate < '20060701' GROUP BY EmployeeID) O ON E.EmployeeID = O.EmployeeID ORDER BY [Employee Name] While it would seem BETWEEN would save Janice a bit of typing, there is a problem with it. BETWEEN corresponds, based on these queries to the same as: WHERE OrderDate >= 20060601 AND OrderDat e<= 20060701 Its the latter one that causes the query to be incorrect as it would potentially include orders placed on July 1st at midnight (20060701 corresponds to July 1, 2006 at 00:00:00). While this would be unlikely in a small retail environment, it is entirely possible in larger operations, especially those which are international in scope. Therefore, the use of BETWEEN in this case is not appropriate. With respect to the GROUP BY, it must appear in the subquery on the Orders table, as given in the answer. When it occurs after the LEFT JOIN, the rows where there is an employee but no order for the month will be lost. Since Janice must report on employees who had no sales, this is unacceptable.
What would happen when you execute the code below in Query Analyzer (SQL Server 2000)

USE Northwind GO CREATE PROCEDURE sp_who AS PRINT 'SURPRISE' GO EXECUTE sp_who

Information about current SQL Server users and processes is displayed. The explanation could be found in the Books Online under Creating a Stored Procedure. One of the sections, named System Stored Procedures which describes how SQL Server looks up the system stored procedure has this note: Important If any user-created stored procedure has the same name as a system stored procedure, the user-created stored procedure will never be executed.
How is Thesaurus data configured in SQL Server 2005 Full-Text Search?

An XML file in the file system named tsxxx.xml where xxx is a code. The thesaurus file for SQL Server 2005 is an XML file containing data and stored in SQL_Server_install_path\Microsoft SQL Server\MSSQL.1\MSSQL\FTDATA\ directory. There is one for each language and it is named tsxxx_.xml, where xxx is the three letter language code.
What does a report model provide in SQL Server 2005 Reporting Services?

A report model provides familiar business names for database tables and fields A Report model provides business names and terms for database fields and tables. It allows for predefined relationships between tables as well as grouping items together logically.

What can tracer tokens measure in SQL Server 2005 transactional replication?

1 and 3 Tracer tokens measure two things. One is the amount of time elapsed between a command being committed on the publisher and being written to the distribution database. The other is from the writing to the distribution database and being committed to a subscriber. This allows you to determine the latencies for transactions moving through your replication topology.
You want to script the execution of an Integration Services package from the command line for use from a Unix scheduler. What utility would you use?

dtexec.exe The dtexec.exe utility is used to configure and execute Integration Services packages from the command line.
What does the sqlwb utility do?

Opens SQL Server 2005 Management Studio. sqlwb.exe actually opens Management Studio and can be configured to optionally open a solution, project, or script file when it starts.
You want to automate the installation of SQL Server 2005 using SMO for your custom application and ensure that the encryption features are available with a service master key. What method would you call to create this key?

The Regenerate method under the ServiceMasterKey object. To create a Service Master Key in SMO, you would get a handle to the ServiceMasterKey object under the Server object and then call the Regenerate method.
How can you determine which Service Broker ports are being used on your server?

Query the system catalog view: sys.conversation_endpoints The system catalog view sys.conversation_endpoints will show you which Service Broker endpoints, and therefore ports, are open on your server.
In Full-Text Search, what is word breaking?

Determining word boundaries. Word breaking involves finding the boundaries of a word. This is different for different languages and SQL Server 2005 includes word breakers for 23 languages.
Can you call Notification Services APIs from unmanaged code?

Yes, but only for simple subscriptions. Notification Services can be called from unmanaged code through a COM interface for simple subscriptions only. Condition based subscriptions are not supported through COM Interop.
Which of the following is true about the Raw File Source in SQL Server 2005 Integration Services?

It does not support an error output. The raw file source has only one output and does not support an error output. It also reads faster than other data sources because it has no parsing or translation and does not use a connection manager.

You have a SQL Server 2005 sales database experiencing performance problems because of heavy I/O activity. You decide to create a snapshot of this database every hour, stored on a separate physical disk array and use that for reporting queries. However the queries still seem slow immediately after snapshot creation. Why?

The snapshot still queries the original database. The snapshot of the production database will only reduce I/O for changed pages. Any data that has not been changed will be read from the source database, which is in this case is experiencing heavy I/O itself.
In Reporting Services 2005, how is Report Builder typically deployed to end users?

One click deployment launched from a menu on the Report Manager home page One click deployment is fast and easy, users click the menu on the Report Manager page. It is not a web application, but rather a .Net Winform application.
Native Web Services require what type of endpoint in SQL Server 2005?

HTTP endpoints Native XML Web Services in SQL Server 2005 require HTTP endpoints to communicate with clients.
If you have a replication scenario with one publisher, one distributor and one subscriber and the transaction isolation level is not set to serializable, what happens when a transaction fails on the publisher?

It is still sent to the distributor and executed on the subscriber. A transaction that fails in the publication database is still sent to the distributor and subscriber. YUou can trap the error, but you would need to trap it on the subscriber as well.
When creating a full-text index on a BLOB column (image, binary or varbinary) where a file is stored, what happens if an incorrect file prefix is stored in the type column? (For instance: if a word document is stored in the image or a varbinary(MAX) column and the value of the type column is '.pdf'.

The row is not full-text indexed and an error message is written to the SQL Server Error Log The answer is the row is not full-text indexed and an error message is written to the SQL Server Error Log. No columns in the row are full-text indexed and an error message is written to the SQL Server Error Log.
In SQL Server 2005 Full-Text Search, you set up a replacement set like this:

<replacement> <pat>SS2K5 </pat> <sub>SQL Server 2005 </sub> <sub>SQL Server 2K5 </sub> </replacement> A search for "SS2K5" doesn't return results with fields that you know contain "SS2K5". What is wrong?

The replacement set does not return results with the search terms, only the specified replacements.

In the SQL Server 2005 thesaurus XML configuration file, what is the expansion set?

Expansion sets are synonyms for the search term and returned as results if they appear along with the search term. The expansion set is the group of values that are synonyms and can be substituted for the search term. For example, an expansion set can be "SS2K5", "SQL Server 2005", "SQL2K5". In this case, fields with any of these 3 values would be returned as a result for searches on "SQL Server 2005".
You are initiating a new replication subscription for one of the remote offices, but don't want to transfer it across the network. The snapshot files are 725MB, too large for your CD burner and there is no tape drive at the remote office. What feature of SQL Server 2005 would help you get the snapshot transferred?

Compressed Snapshots In SQL Server 2005, you can specify a snapshot to be compressed and it will be compressed using the CAB format. If it compresses enough, you should be able to burn it onto a CD.
The TRUSTWORTHY database property is by default?

Off The correct answer is off The TRUSTWORTHY database property indicates whether the installed instance of SQL Server trusts the database such that it can reach out and perform actions outside the database. By default it is OFF such that the database to reduce certain threats that can result from attaching a database that contains potentially harmful code
Where are Notification Services event messages logged in SQL Server 2005?

In the Windows Application Log Event messages are logged in the Windows Application log.

When you install SQL Server 2005 and create a new database, is a Database Master Key created?

No A database master key is not created when a database is created. It must be created by an administrator.
What does the DEALLOCATE statement do in SQL Server 2005?

Remove a reference to a cursor. This statement is used to remove cursor references. If this is the last reference being removed, the cursor's resources are released.
Report Builder has no built in support for source control. Which of the following choices could be implemented if you decided that those reports needed to be under source control?

Have users save the RDL files locally and check into source control using a source control utility, or write code to script them out each night and check them into source control Users can do faux source control by just saving copies of their RDL files locally before they make a change. Beyond that, you either teach them how to use a source control utility or you write a utility you can run on a schedule.

Setting the TRUSTWORTHY database property to ON allows you to execute the following from within the context of the database

Objects from unsigned CLR assemblies with EXTERNAL_ACCESS or UNSAFE permissions In order to execute objects from CLR assemblies with EXTERNAL_ACCESS or UNSAFE permissions, the assemby must either be signed with a key pair or the database hosting the assembly must have the TRUSTWORTHY database property set to ON. Executing the other answers is essentially controlled by permissions. Setting the TRUSTWORTHY database property to ON also allows you to use the EXECUTE AS clause to allow impersonation outside the scope of the database within the instance but this was not one of the answers.
What tool is available for ad hoc reporting by non IT end users in Reporting Services 2005?

Report Builder Report Builder is bundled as part of Reporting Services 2005 and is targeted at end users needing to build ad hoc reports. BI Design Studio could be used, but typically requires more time and experience to use than the average end user will be willing to invest.
You have just upgraded your SQL Server 2000 instance on Windows 2000 to SQL Server 2005. You are looking to begin implementing encryption capabilities and need to choose an algorithm for your data. Which of the following is not available to you?

128-bit AES While all of these are valid encryption algorithms on SQL Server 2005, the AES algorithms (128-bit, 192-bit, and 256-bit) are not supported on Windows XP or Windows 2000. To use these, you would need to upgrde to Windows 2003.
Which types of replication work with Oracle publishers?

Snapshot and transactional Oracle publishing with SQL Server works as both snapshot and transactional publication issues.
What does @@textsize return?

The current value of the TEXTSIZE option for the SET command. This returns the current value of the TEXTSIZE option that can be changed with the SET command. The default is 4096 bytes.
In configuring the thesaurus configuration file for SQL Server 2005 Full-Text Search, you set the diacritics_sensitive value to 1. What does this mean?

It means the sets in this file are accent sensitive. The diacritics_sensitive determines if the terms in the expansion and replacement sets are accent sensitive. A value of 0 means accent insensitive and a value of 1 means accent sensitive.
Before a user can build reports using Report Builder in Reporting Services 2005, which one of the following steps must be done first?

Build and deploy a model Report Builder requires a model and that model cannot be defined using Report Builder. The advantage of using models is that users do not need to understand SQL statements to build a report (but they will still benefit from a basic understanding of the relationships between various bits of data)

What does the CREATE SERVICE statement do in SQL Server 2005?

This statement is used to setup new tasks for Service Broker queues. This statement is ue to create a new Service Broker service that is a set of tasks that are run on messages.
After you've completed a backup for your Sales server to disk, you want to be sure that this backup is intact and able to be used for restores before writing it to tape. What command will help you here?

RESTORE VERIFYONLY After a backup file has been written to disk or tape, its integrity can be checked with the RESTORE VERIFYONLY command. This command will verufy the backup set is complete and that the files are readable.
What is the result of the following query?

declare @a int declare @b int set @a = 5 set @b = 11 select @a = @a ^ @b , @b = @b ^ @a, @a = @a ^ @b print '@a = '+convert(varchar,@a) print '@b = '+convert(varchar,@b) @a = 11 , @b = 5 Here is the explanation: Step 1 @a has the value of 5 and is binairy 101 @b has the value of 11 and is binairy 1011 After select @a = @a ^ @b , @b = @b ^ @a, @a = @a ^ @b the values are @a will get the value from 101 ^ 1011 = 1110 (=14) @b have stil the value of 1011 (=11) Step 2 After select @a = @a ^ @b , @b = @b ^ @a, @a = @a ^ @b The values are @a will stay at the value 1110 (=14) @b will get the value from 1011 ^ 1110 = 101 (=5) Step 3 After select @a = @a ^ @b , @b = @b ^ @a, @a = @a ^ @b @a will get the value from 1110 ^ 101 = 1011 (=11) @b will stay at the value 101 (=5)
Out of the box Report Builder supports two report level fields that can be shown on a report. Which option below has those two options?

The current filter and the number of rows that matched that filter

By default, the current filter definition and the number of rows that matched the filter are added to the end of the report. They can be removed and added back as needed.
Can a particular event in SQL Server 2005, such as the CREATE USER command, have more than one DDL trigger assigned to it?

Yes An event can have multiple triggers assigned to it.

You accidently delete an application from an instance of SQL Server 2005 Notification Services. However you have not removed the database, nor the application objects. Can you re-associate the application with the same SSNS instance?

No You cannot re-assocaite the application because when you add the application, SSNS recreates the objects. If they already exist, the create fails.
How many users can be added to an application role in SQL Server 2005?

None This is a trick questions. No users are added to application roles. Application roles are invoked by a user.
What algorithm is used to encrypt the Database Master Key when it is created?

Triple DES When you create a Database Master Key, it is encrypted using the password you supply with the Triple DES algorithm.
Which protocols support Kerberos authentication on SQL Server 2005?

TCP/IP Only those clients connecting with TCP/IP can use Kerberos authentication.

You have a few new SQL Server 2005 server instances and you want to be sure that SQL authenticated logins must abide by the password policy. On this platforms can you enforce this?

Windows 2003 Server You can only enforce password policy on the Windows 2003 Server platform and newer.
You are setting up a native XML web service on your SQL Server 2005 to respond to inventory requests. How can you you be sure that a SOAP queries that are looking for a WSDL response will be provided?

Use the WSDL=DEFAULT parameter in the create endpoint statement. When using the CREATE ENDPOINT command, you can specify the WSDL=DEFAULT parameter to generate a default WSDL response or use WSDL="spname" where spname is the name of a custom stored procedure to return WSDL responses.
Where can you view the list of server-scoped DDL triggers?

The Object Explorer for the server has a "Triggers" folder. The server-scoped DDL triggers will appear in Management Studio in the Object Explorer under the "Triggers" folder.
You want to be sure that your reporting solutions using a database snapshot are properly protected from disaster. How can you back up your database snapshots?

You cannot back up a database snapshot. A database snapshot cannot be backed up or restored.
Using Report Builder, which of the following is the best statement about the formatting options for Boolean columns?

Booleans are formatted as True/False and there are no other built in options, but you could build an expression using IIF that would let you do other formatting From the format dialog there are no extra formatting options for Booleans, Report Builder renders them as True/False. Writing an expression that you add to the model view is the easiest way to work around this limitation.
What is the easiest way to capture the SQL statement for a Report Builder report you're troubleshooting?

Run Profiler Profiler will work as long as you have permissions to profile the server and is the the best solution because it requires no change to the Report Server itself. There is a way to log all report SQL to a log file, but that option was not listed here and is better used if you want to do analysis rather than troubleshooting.
Clicking File, Save in Report Builder does which of the following?

Saves the report to the report server File|Save writes the report to the Report Server. Users have the option to also save the report to disk by using File|Save to File. Report Builder users cannot modify the model.
Which of the following choices show the three report formats supported by Report Builder ?

Table, Matrix, Chart Report Builder can build a report formatted as a table, chart, or matrix (cross tab), but only ONE can be used in any given report.
Using Report Builder, which of the following statements is correct about formatting numbers?

Users can pick from a small number of predefined formats and they have the option to specify a custom format There are give built in formats; general, currency, percentage, two place decimal, and exponent. Users can also define a custom format using a .Net format string.
True or false, Report Builder supports using the LIKE function inside filters?

False There is no LIKE support, the next best thing is the CONTAINS function which works as if you specified both a leading and trailing wild card.
Which RAID levels store parity information?

RAID 5 Only RAID 5 (of those listed) contains parity information.


You have a large table that you wish to partition to improve performance. The table contains many columns of data about customers and you decide that basic information about each customer will remain in the current table. Extended information, such as shipping instructions, secretaries' names, etc. will be moved to a new table along with the PK. What type of partitioning is this?

Vertical partitioning If you are moving some columns from one table to a new table, this is vertical partitioning.
On which platforms can you use Instant File Initialization to improve database growth performance in SQL Server 2005?

Windows 2003 and XP Pro Both Windows 2003 Server and later as well as Windows XP Professional support Instant File Initialization.
You have created a database snapshot on SQL Server 2005 for the sales database to capture the end-of-month activity. The next day your server fails and you need to recover to a standby server using the previous night's backups. How do you recover the snapshot?

There is nothing you can do. The snapshot is lost. Database snapshots cannot be backed up, so once the server failed, the database snapshot was lost.

Using Reporting Services 2005, it is true or false that subreports execute a query against the datasource once for every detail row in the report?

True True. Subreports can be used for a master-detail relationship, or the subreport can be a separate item, but in either case RS will query to get the data for the report once for each detail row. If end users are going to only occasionally look at the data you're displaying in the subreport or only view it for a few rows, a better option is to create a link to the other report.
You have noticed in both your SQL Server 2000 and 2005 instances that when a database grows in SQL Server, there is a delay in the database response. Why is that?

Once the file is grown, zeros are written to the new space, causing a delay. When a database file grows, unless instant file initialization is turned on, the server must allocate disk space and then write 0s into all that space. This zero-ing out of the file creates the delay.
Which utility is used to administer SQL Server 2005 Notification Services instances?

nscontrol.exe The nscontrol application can be used with various parameters to administer a SQL Server 2005 Notification Services instance.
You want to be sure that your Scalable Shared Database is as available as possible. Which of the following is not needed for this?

Use Database Mirroring to fail over between the old reporting database and the new one. The update process for a Scalable Shared database with minimal downtime involves putting out a new copy of the database, detaching the old database from each server, and then attaching the new database to each server.
What is the cost threshhold for parallelism in SQL Server 2005?

This is the number of seconds that a serialplan cannot exceed if it is to be used. A parallel plan is used if the estimate exceeds this value. This is the threshold at which SQL Server determines whether a serial or parallel plan is to

be used. When SQL Server calculates that a serial plan exceeds the threshold, it will elect to use a parallel plan instead.
You have a Scalable Shared Database setup for reporting purposes on SQL2. You want to be able to keep a point in time view of the reporting database each month. What can you do?

Make a new copy of the production database each month and then copy that to the SAN. Attach it as a new Scalable Shared Database each month to the reporting servers. A Scalable Shared Database does not support database snapshots, so you would have to manually create a new database each month with the data view you need and add this as a new Scalable Shared Database to the SAN and each reporting server.
You have an old database that needs to run in compatibility mode 65 on your SQL Server 2005 server. Which framework would you use to manage this database programmatically?

SQL-DMO SMO does not support compatibility modes 60 or 65, so you would need to use DMO instead.

You have two Service Broker instances running. One is on SQL1 with the default collation and the other is on SQL2 setup for French collation. Which collation is used for Service Broker messages sent between the instances?

Service Broker does not consider the collation, using byte-by-byte matching for names. Neither collation is used. Service Broker operates in a collation independent method that removes collation information from the messages.
What does the max full-text crawl range option do?

Determines the number of partitions used in an index crawl. This option helps optimize the full-text indexing process by specifying the number of partitions the SQL Server uses during index crawls.
Which of the following is not an allocation unit in SQL Server 2005?

TEXT_IN_ROW_DATA The three types of allocation units are: IN_ROW_DATA, LOB_DATA, and ROW_OVERFLOW_DATA. Each heap or index has IN_ROW_DATA which holds part of the data. LOB_DATA is used for large object data types and ROW_OVERFLOW_DATA is used for varible length data that causes a row to exceed the 8060 byte limit.
Which of the following is the best use for a Scalable Shared Database in SQL Server 2005?

A reporting database server A scalable shared database is a feature that allows you to setup read-only database on a separate server for reporting purposes. This database provides an identicle view of your data from another server.
You are loading 100 rows of data into a narrow table that is heavily used by your production inventory queries. It was recommended that you drop the indexes on the table before the load and then rebuild them after the load is complete. Is this something you would do?

This does not make sense.

For such a small number of rows, it is unlikely that dropping the indexes will improve the performance of your load. If this were 100,000 rows, then it might make sense.
How can SQL Server Agent Mail send messages in SQL Server 2005?

SQL Mail through Extended MAPI or Database mail. SQL Server Agent Mail can be configured to use Database Mail or Extended MAPI.
What is the scale of measurement for the cost threshold for parallelism setting in SQL Server 2005?

Seconds This value measures the number of seconds for a plan where the optimizer chooses between serial and parallel plans.

Which of the following statements best describes the filter capabilities of Report Builder?

Users can do equals, greater than, less than, etc, plus they can do logical AND, OR, NOT operations. Users can also group filters to allow more advanced filters. While it looks a little different than you may be used to, the filter builder is reasonably rich, allowing most standard evaluation types and rich boolean comparisons. The only weak spot in the set is no support for LIKE, you have to make do with CONTAINS.
True or false, Report Builder supports user defined run time parameters?

True Absolutely true. Users can define any portion of a filter to be a run time prompt, letting other users easily change the filter as needed. Not only is it easy to set up, Report Builder automatically populates a list of all possible choices based on the column being filtered.
Using Report Builder that is bundled with Reporting Services 2005, which of the following would work as a way to add a derived field to a report?

Add a field to the model in Report Builder using the built in formula/function support While Report Builder cannot be used to build or maintain models, it does allow you to add a virtual field that exists only within that report - to the end user it looks like the model is being modified.
If you absolutely need a report to look the same regardless of what OS or viewing software is being used, which of the following file formats would be the best choice?

TIFF TIFF is the correct answer. By rendering as an image there are no concerns about different fonts, problems with page breaks, etc. PDF's are almost as good and more commonly used of course, with the advantage that document maps are translated to bookmarks that are usable - something not possible with a raw image.
True or false, Report Builder offers direct export to a Microsoft Access database as one of its supported export options?

False False. Supported formats include Excel, CSV, XML, TIFF, MHTML, and PDF. XML or CSV could be easily imported into Access, but there is way to add the data directly from Report Builder

When discussing image support in Report Builder, which of the following is the most accurate statement?

Users can add one or more images, but they will appear in the header or footer of the report, they cannot be added to the detail row. Images that are stored as row data in the database can be rendered at the detail level. Multiple images can be added, but they appear in the header or footer depending on where placed on the report. The only way to get an image at the detail level (row based) is to have it be part of the database and included in the model.
If you received a "Performance Critical" status in the SQL Server 2005 replication monitor, what does this mean?

The latency between transaction commits at the publisher and subscriber exceeds the warning level. This status can actually mean two different things. Either the latency between the commit of a transaction at the publisher and the same commit at the subscriber is exceeding some level in a transactional level or not enough rows are being processed in a merge replication scenario.
Which of the following modules within SQL Server 2005 cannot be signed with a digital signature?

DDL triggers DDL triggers cannot be signed, but all the other objects can.
What does this return?

declare @i int select @i = -5 select +@i

-5 This will return -5 as the result. The + operator functions as a unary plus operator, which means that it performs no operation on the value it preceeds.
You have installed a US English SQL Server 2000 instance with the default options, collation, and sorting. What does this return:

create table MyTable ( Mychar varchar(20)) go insert Mytable select 'Apple' insert Mytable select 'ant' insert Mytable select 'Ball' go select * from MyTable where Mychar like '[^a]%'

Ball This should return "Ball" only since the ^ operator means not matching the next character. In this case, the first character should not be an "A".
Where does Profiler store its temporary data in SQL Server 2005?

In the directory stored in the system variable TEMP. Profiler uses the location specified for the TEMP system variable.

What is the Service Broker Identifier ?

A GUID that identifies the database on which Service Broker is running. Each database has a Service Broker identifier. This is a GUID in the service_broker_GUID column that identifies the databases on which Service Broker is running. It ensure that messages are delivered to the right database.
You are looking to import a large amount of data from a remote OLEDB data source that is not a text file. Which of the following techniques can you use?

Use the select * from OPENROWSET(BULK...) command. SQL Server 2005 includes a new option with the OPENROWSET command for getting large amounts of data from an OLEDB data source. It is the BULK option and works similar to the BULK INSERT command.
How are modified extents tracked in SQL Server 2005 (which internal structures)?

Differential Change Map and Bulk Change Map There are two internal structures that track extents modified by bulk copy operations or that have changed since the last full backup. They are the Differential Changed Map (DCM) and the Bulk Changed Map (BCM).
What does this return?

select (1324 & 1024)

1024 This performs a bitwise AND operation between the two integers and sets the result to this. Since 1024 is a single set bit in it's value, if the corresponding bit is set to 1, then in the result the bit is set to 1. In this case, since no other bits would generate two 1s, the result is equivalevt to the mask, or 1024.
What does the Log Reader agent in SQL Server 2005 replication do?

This agent reads the publisher log for transactions to send to the distributor. This agent is tasked with reading the transaction log in transactional replication and moving those transactions that need to be replicated to the distributor.
You are performing an update of your Scalable Shared Database and receive note that two reports run at the same time received different results. These reports were both run during your update. What type of update did you perform?

A rolling update When performing a rolling update, doing the detach and attach on each server as opposed to detaching from all then attaching to all, it is possible that different reporting servers will display different results.
What does a @@fetch_status of -2 mean in SQL Server 2005?

The row being fetched is missing. This means that the row that was being fetched from the cursor is missing. What is SQL Server ? SQL Server is a DBMS system provided by Microsoft. SQL Server is sometimes mistakenly referred to as SQL.

Error severity 13 indicates what?

Transactional deadlock errors. This level of error severity indicates a transaction deadlock error.
In which order do you perform an upgrade to SQL Server 2005 for replicated databases?

Distributor, Publisher, then Subscriber. You always perform an upgrade in this order: distributor, publisher, subscriber.
How many Service Packs will be released for SQL Server 2005 in 2007?

Explanation: The answer is up in the air and this is more of a poll than a real QOD. Based on the ways things are going, the staff here sees just 1, though our hope would be that 3 or 4 would be released.
You setup a linked server from a SQL Server 2000 server to your new SQL Server 2005 server (with defaults), however you cannot execute procedures on the 2005 server. Why not?

You need to enable RPC. By default, RPC is disabled in SQL Server 2005. You need to set the "remote access option" in your server configuration to 1 to allow the execution of stored procedures from a remote server.
What is the recommended way to send mail from SQLAgent in SQL Server 2005?

Database Mail You can use either Database Mail or SQLMail with SQL Agent in SQL Server 2005. However since SQLMail will be removed, it is recommended that you use Database Mail.
When you create a new Message Type in the SQL Server 2005 Service Broker, what does the Authorization parameter signify?

The owner of the message type. This parameter determines the owner of the message type. This defaults to the current user.
What the heck does ATN2 do?

The angle between the x-axis and a ray. This is a mathematical function that returns the angle between the positive x-axis and the ray that passes through the two coordinates passed in. The angle is in radians.
How does a differential backup know which extents have changed so that it can be very quickly run?

The DCM tracks changes. The differential backup reads the extents from this structure. A differential backup uses the Differential Change Map to determine which extents have changed and need to be include in the backup. This greatly speeds the differential backup process.
If you run this, what does it return?

select applock_mode('public', 'SalesApp', 'Transaction') The type of lock being held by an application that requested it. This command returns the lock mode held by an application that was requested with the sp_getapplock procedure.

insert mytable select '' insert mytable select ' ' select * from mytable where mychar = '' select * from mytable where mychar = ' '
How many rows are returned by these two select statements?

2 and 2 Each select statement actually returns 2 rows. You can use this script to check this: create table mytable ( id int identity(1,1) , mychar varchar(20) ) go insert mytable select null insert mytable select '' insert mytable select ' ' go set ansi_nulls on set ansi_null_dflt_on on select * from mytable where mychar is not null select * from mytable where mychar <> '' and mychar is not null select * from mytable where mychar <> ' ' and mychar is not null select * from mytable where mychar = '' select * from mytable where mychar = ' ' set ansi_null_dflt_on off set ansi_nulls off go drop table mytable
What does the Queue Reader Agent do in SQL Server 2005 replication?

This agent reads the subscriber logs and moves changes back to the publisher. This agent is used when the queued update model is chosen with transactional replication. It moves changes from the subscribers back to the publishers.
What are the three possible functions of the plus (+) operator in SQL Server 2005, the base installed T-SQL?

Add, string concatenation, unary plus The three functions are Add, String Concatenation, and Unary Plus.

The Sort component in SQL Server 2005 Integration Services is what type of component?

Blocking Transformation The Sort component is a blocking transformation meaning that it needs all rows in order to perform its function.

1) What is a class ?

A class is the generic definition of what an object is . A Class describes all the attributes of object, as well as the methods that implements the behavior of member object. That means, class is a template of an object. Easy way to understand a class is to look at an example . In the class Employee given below, Name and Salary are the attributes of the class Person , Setter and Getter methods are used to store and fetch data from the variable.

public class Employee { private String name; private String Salary; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSalary () { return Salary; } public void setSalary (String Salary) { this. Salary = Salary; } }

2) What is an Object?

Object is an instance of a class, it contains real values instead of variables. For example, lets create an instance of class Employee called Jhon.

Employee Jhon = new Employee(); Now we can access all the methods in the class Employee via object Jhon as shown below.

Jhon.setName(XYZ);

3) What are the Access Modifiers in C# ?

Different Access Modifier are - Public, Private, Protected, Internal, Protected Internal

Public When a method or attribute is defined as Public , It can be accessed from any code in project. For example in the above Class Employee , getName(), setName() etc are public.

Private - When a method or attribute is defined as Private , It can be accessed by any code within the containing type only. For example in the above Class Employee , attributes name and salary can be accessed with in the Class Employee Only. If an attribute or class are defined without access modifiers , its default access modifier will be private.

Protected - When an attribute and methods are defined as protected, it can be accessed by any method in inherited classes and any method within the same class. The protected access modifier cannot be applied to class and interfaces. Methods and fields in a interface cannot be declared protected.

Internal If an attribute or method is defined as Internal , Access is restricted to classes within the current project assembly Protected Internal If an attribute or method is defined as Protected Internal , Access is restricted to classes within the current project assembly and types derived from the containing class.

4) Define Static Members in C# ?

If an attributes value had to be same across all the instances of the same class , static keyword is used. For example if the Minimum salary should be set for all employees in the employee class, use the following code private static double MinSalary = 30000; To access a private or public attributes or methods in a class, at first an object of the class should be created . Then using that instance of class , attributes or methods can be accessed. To access a static variable, we don't want to create an instance of the class having the static varibale . We can directly refer that static variable as shown below.

double var = Employee.MinSalary ;

5) Define Reference Types in C# ?

Let us explain this with an example . For the code given below,

Employee emp1 ; Employee emp2 = new Employee(); emp1 = emp2;

Here emp2 has an object instance of Employee Class . But emp1 object is set as emp2. What this means is that object emp2 is refereed in emp1 and not that emp2 is copied into emp1. When a change is made in emp2 object, corresponding changes can be seen in emp1 object.

6) Define Property in C# ?

Properties are a type of class member , that are exposed to outside world as a pair of Methods.For example for the static field Minsalary, we will Create a property.

private double minimumSalary ; public static double MinSalary { get { return minSalary; } set { minSalary = value; } }

So when we execute the following lines code

double minSal = Employee. MinSalary;

get Method will get triggered and value in minimumSalary field will be returned.When we execute ,

Employee. MinSalary = 3000;

set Method will get triggered and value will be stored in minimumSalary field .

7) Define Overloading in C# ?

When methods are created with same name , but with different signature its called overloading. For example , WriteLine method in console class is an example for overloading. In first instance , it takes one variable. In the second instance , WriteLine method takes two variable.

Console.WriteLine(x); Console.WriteLine("The message is {0}", Message); Different type of overloading in C# are

1)Constructor overloading 2)Function overloading. 3)Operator overloading

8) Define Constructor Overloading in C# .net ?

In Constructor overloading, n number of constructors can be created for same class. But the signatures of each constructor should vary. For example

public class Employee { public Employee()

{} public Employee(String Name) {} }

9) Define Function Overloading in C# .net ?

In Function overloading, n number of functions can be created for same class. But the signatures of each function should vary. For example

public class Employee { public void Employee() {} public void Employee(String Name) {} }

10) Define Operator Overloading in C# .net ?

We had seen function overloading in the previous example.For operator Overloading , we will have look at the example below. We define a class rectangle with two operator overloading methods.

class Rectangle { private int Height; private int Width; public Rectangle(int w,int h) { Width=w; Height=h; } } public static bool operator >(Rectangle a,Rectangle b)

{ return a.Height > b.Height ; }

public static bool operator <(Rectangle a,Rectangle b) { return a.Height < b.Height ; } }

Let us call the operator overloaded functions from the method below. When first if condition is triggered, first overloaded function in the rectangle class will be triggered. When second if condition is triggered, second overloaded function in the rectangle class will be triggered.

public static void Main() { Rectangle obj1 =new Rectangle(); Rectangle obj2 =new Rectangle(); if(obj1 > obj2){ Console.WriteLine("Rectangle1 is greater than Rectangle2"); }

if(obj1 < obj2) { Console.WriteLine("Rectangle1 is less than Rectangle2"); } }


11) Define Data Encapsulation in c# ? Data Encapsulation is defined as the process of hiding the important fields from the end user. In the above example , we had used getters and setters to set value for MinSalary. Idea behind this is that , private field minimumSalary is an important part of our classes. So if we give a third party code to have complete control over the field without any validation it can adversely affect the functionality. This is in line with OOPS Concept that an external user should know about the what an object does. How it does it should be decided by the program. So if a user set a negative value for MinSalary , we can put a validation in set method to avoid negative values as shown below set

{ if(value > 0) { minSalary = value; } } 12) Define Inheritance in C#? In object-oriented programming (OOP), inheritance is a way to reuse code of existing objects. In inheritance there will be two classes - base class and derived classes . A class can inherit attributes and methods from existing class called base class or parent class. The class which inherits from base class is called derived classes or child class. For more clarity on this topic , let us have a look at 2 classes shown below. Here Class Car is Base Class and Class Ford is derived class. class Car { public Car() { Console.WriteLine("Base Class Car"); } public void DriveType() { Console.WriteLine("Right Hand Drive"); } } class Ford : Car { public Ford() { Console.WriteLine("Derived Class Ford"); } public void Price() { Console.WriteLine("Ford Price : 100K $"); } } When we execute following lines of code , Ford CarFord = new Ford(); CarFord.DriveType(); CarFord.Price(); Output Generated is given below. Base Class Car Derived Class Ford Right Hand Drive Ford Price : 100K $

What this means is that , all the methods and attributes of Base Class car is available in Derived Class Ford. When an object of class Ford is created , constructors of the Base and Derived class get invoked. Even though there is no method called DriveType() in Class Ford, we are able to invoke the method because of inheriting Base Class methods to derived class. 13) Define Multiple Inheritance in C# ? In C# , derived classes can inherit from only one base class. If you want inherit multiple base classes, use interface. 14) What is Polymorphism in C#? Ability of a programming language to process objects in different ways depending on their data type or class is known as Polymorphism. There are two types of polymorphism 1) Compile time polymorphism. Best example is Overloading 2) Runtime polymorphism. Best example is Overriding 15) Define Virtual Keyword in C#? When we want to give permission to derived class to override a method in base class, Virtual keyword is used . For example lets us look at the classes Car and Ford as shown below. class Car { public Car() { Console.WriteLine("Base Class Car"); } public virtual void DriveType() { Console.WriteLine("Right Hand Drive"); } } class Ford : Car { public Ford() { Console.WriteLine("Derived Class Ford"); } public void Price() { Console.WriteLine("Ford Price : 100K $"); } public override void DriveType() { Console.WriteLine("Right Hand "); } }

When following lines of code get executed Car CarFord = new Car(); CarFord.DriveType(); CarFord = new Ford(); CarFord.DriveType(); Output is as given below. Base Class Car Right Hand Drive Base Class Car Derived Class Ford Right Hand

16) Define overriding in c# ? To overide a base class method which is defined as virtual , Overide keyword is used. In the above example , method DriveType is overrided in derived class. 17) Define Method Hiding in C# ? If the derived class doesn't want to use methods in base class , derived class can implement the same method in derived class with same signature. For example in the classes given below, DriveType() is implemented in the derived class with same signature. This is called Method Hiding. class Car { public void DriveType() { Console.WriteLine("Right Hand Drive"); } } class Ford : Car { public void DriveType() { Console.WriteLine("Right Hand "); } } 18) Define Abstract Class in C#? If we don't want a class object to be created define the class as abstract. An abstract class can have abstract and non abstract classes. If a method in abstract id defined as abstract , it must be implemented in derived class. For example , in the classes given below , method DriveType is defined as abstract. abstract class Car { public Car() {

Console.WriteLine("Base Class Car"); } public abstract void DriveType(); } class Ford : Car { public void DriveType() { Console.WriteLine("Right Hand "); } } Method DriveType get implemented in derived class. 19) Define Sealed Classes in c# ? If a class is defined as Sealed it cannot be inherited in derived class. Example is given below. public sealed class Car { public Car() { Console.WriteLine("Base Class Car"); } public void DriveType() { Console.WriteLine("Right Hand "); } } 20) Define Interfaces in C# ? An interface is similar to a class with method signatures. There wont be any implementation of the methods in Interface. Classes which implements interface should have implementation of methods defined in abstract class. interface Breaks { void BreakType(); } interface Wheels { void WheelType(); } class Ford : Breaks, Wheels { public Ford() { Console.WriteLine("Derived Class Ford"); }

public void Price() { Console.WriteLine("Ford Price : 100K $"); } public void BreakType() { Console.WriteLine("Power Break"); } public void WheelType() { Console.WriteLine("Bridgestone"); } }

21) Define Constructor in C# ? Constructor is a special method that get invoked / called automatically whenever an object of a given class gets instantiated. For example in our class car constructor is defined as shown below public Car() { Console.WriteLine("Base Class Car"); } When ever an instance of class car is created from the same class or its derived class(Except Few Scenarios) Constructor get called and sequence of code written in the constructor get executed. 22) Define Destructor in C# ? Destructor is a special method that get invoked / called automatically whenever an object of a given class gets destroyed. Main idea behind using destructor is to free the memory used by the object.

SQL joins are actually easy concepts. But peope usually seems to get confused between them. Below you can find a well known way to remember and understand visual explanation on how sql joins relate to their corresponding names.

Select [ fields ] from A left join B on A.key = B.key

Left Join

Select [ fields ] from A right join B on A.key = B.key

Right Join

Select [ fields ] from A inner join B on A.key = B.key

Inner Join

Select [ fields ] from A left join B on A.key = B.key where A.key is null

Left Join With NULL

Select [ fields ] from A left join B on A.key = B.key where B.key is null

Right Join With NULL

Select [ fields ] from A full outer join B on A.key = B.key

Full Join

Select [ fields ] from A full outer join B on A.key = B.key where A.key is null or B.key is null

Full Join With NULL

SQL Interview Questions on Database Basics


1. What is DBMS ?

Database management system is a collection of programs that enables user to store , retrieve , update and delete information from a database .

2. What is RDBMS ?

Relational Database Management system (RDBMS) is a database management system (DBMS) that is based on the relational model . Data from relational database can be accessed or reassembled in many different ways without having to reorganize the database tables . Data from relational database can be accessed using a API , Structured Query Language (SQL)

3. What is SQL ?

Structured Query Language(SQL) is a language designed specifically for communicating with databases. SQL is an ANSI (American National Standards Institute) standard .

4. What are the different type of Sql's?

1. DDL Data Definition Language DDL is used to define the structure that holds the data. For example. table

2. DML Data Manipulation Language DML is used for manipulation of the data itself. Typical operations are Insert,Delete,Update and retrieving the data from the table

3. DCL Data Control Language DCL is used to control the visibility of data like granting database access and set privileges to create table etc.

5. What are the Advantages of SQL 1. SQL is not a proprietary language used by specific database vendors. Almost every major DBMS supports SQL, so learning this one language will enable programmer to interact with any database like ORACLE, SQL ,MYSQL etc. 2. 3. SQL is easy to learn. The statements are all made up of descriptive English words, and there aren't that many of them. SQL is actually a very powerful language and by using its language elements you can perform very complex and sophisticated database operations.

6. what is a field in a database ? A field is an area within a record reserved for a specific piece of data. Examples: Employee Name , Employee ID etc

7. What is a Record in a database ? A record is the collection of values / fields of a specific entity: i.e. a Employee , Salary etc

8. What is a Table in a database ? A table is a collection of records of a specific type. For example, employee table , salary table etc .

SQL Interview Questions on Database Transactions

9. What is a database transaction? Database transaction take DB from one consistent state to another. At the end of the transaction the system must be in the prior state if transaction fails or the status of the system should reflect the successful completion if the transaction goes through.

10. What are properties of a transaction? Properties of the transaction can be summarized as ACID Properties.

1. Atomicity In this , a transaction consists of many steps. When all the steps in the transaction go completed it get reflected in DB or if any step fails, all the transactions are rolled back.

2. Consistency The database will move from one consistent state to another if the transaction succeeds and remain in the original state if the transaction fails.

3. Isolation Every transaction should operate as if it is the only transaction in the system

4. Durability Once a transaction has completed successfully, the updated rows/records must be available for all other transactions on a permanent basis

11. What is a Database Lock? Database lock tell a transaction if the data item in questions is currently being used by other transactions.

12. What are the type of locks? 1. Shared Lock When a shared lock is applied on data item, other transactions can only read the item, but cant write into it.

2. Exclusive Lock When a exclusive lock is applied on data item, other transactions cant read or write into the data item.

SQL Interview Questions on Database Normalization


13. What are the different type of normalization? In database design , we start with one single table, with all possible columns. Lot of redundant data would be present since its a single table. The process of removing the redundant data, by splitting up the table in a well defined fashion is calle d normalization.

1. First Normal Form (1NF) A relation is said to be in first normal form if and only if all underlying domains contain atomic values only. After 1NF , we can still have redundant data

2. Second Normal Form (2NF) A relation is said to be in 2NF if and only if it is in 1NF and every non key attribute is fully dependent on the primary key. After 2NF , we can still have redundant data

3. Third Normal Form (3NF) A relation is said to be in 3NF if and only if it is in 2NF and every non key attribute is non-transitively dependent on the primary key

SQL Interview Questions on Database Keys and Constraints


14. What is a primary key?

A primary key is a column whose values uniquely identify every row in a table. Primary key values can never be reused. If a row is deleted from the table, its primary key may not be assigned to any new rows in the future. In the examples given below Employee_ID field is the primary key .

1. To define a field as primary key, following conditions had to be met : 2. No two rows can have the same primary key value. 3. Every row must have a primary key value 4. Primary key field cannot be null 5. Values in primary key columns can never be modified or updated.

15. What is a SQL Composite Primary Key A Composite primary key is a set of columns whose values uniquely identify every row in a table. For example , in the table given above , if "Employee_ID" and "Employee Name" together uniquely identifies a row its called a Composite Primary Key . In this case , both the columns will be represented as primary key .

16. What is a Composite Primary Key ? A Composite primary key is a set of columns whose values uniquely identify every row in a table. For example , in the table given above , if "Employee_ID" and "Employee Name" together uniquely identifies a row its called a Composite Primary Key . In this case , both the columns will be represented as primary key .

17. What is a Foreign Key ? When a "one" table's primary key field is added to a related "many" table in order to create the common field which relates the two tables, it is called a foreign key in the "many" table. In the example given below , salary of an employee is stored in salary table . Relation is established via foreign key column Employee_ID_Ref which refers Employee_ID field in Employee table .

18. What is a Unique Key ? Unique key is same as primary with difference being existence of null . Unique key field allows one value as NULL value .

SQL Interview Questions on SQL Commands


19. Define SQL Insert Statement? SQL INSERT statement is used to add rows to a table. For a full row insert , SQL Query should start with insert into statement followed by table name and values command followed by the values that need to be inserted into the table .Insert can be used in several ways:

1. To insert a single complete row 2. To insert a single partial row

20. Define SQL Update Statement? SQL Update is used to update data in a row or set of rows specified in the filter condition . The basic format of an SQL UPDATE statement is ,Update command followed by table to be updated and SET command followed by column names and their new values followed by filter condition that determines which rows should be updated

21. Define SQL Delete Statement? SQL Delete is used to delete a row or set of rows specified in the filter condition .The basic format of an SQL DELETE statement is ,DELETE FROM command followed by table name followed by filter condition that determines which rows should be updated

22. What are wild cards used in database for Pattern Matching ? SQL 'Like' search takes more time to process . So before using like operator following tips should be considered . Don't overuse wild cards. If another search operator will do, use it instead. When you do use wild cards, try to not use them at the beginning of the search pattern unless absolutely necessary. Search patterns that begin with wild cards are the slowest to process. Pay careful attention to the placement of the wild card symbols. If they are misplaced, you might not return the data you intended

SQL Interview Questions on SQL Joins


23. Define Join and explain different type of joins? In order to avoid data duplication , data is stored in related tables . Join keyword is used to fetch data from related table. Join return rows when there is at least one match in both tables . Type of joins are

Right Join Return all rows from the right table, even if there are no matches in the left table . Outer Join Left Join Return all rows from the left table, even if there are no matches in the right table . Full Join Return rows when there is a match in one of the tables .

24. What is Self-Join? Self-join is query used to join a table to itself. Aliases should be used for the same table comparison.

25. What is Cross Join? Cross Join will return all records where each row from the first table is combined with each row from the second table.

SQL Interview Questions on Database Views


26. What is a view? Views are virtual tables. Unlike tables that contain data, views simply contain queries that dynamically retrieve data when used.

27. What is a materialized view?

Materialized views is also a view but are disk based . Materialized views get updated on specific duration, base upon the interval specified in the query definition. We can index materialized view.

28. What are the advantages and disadvantages of views in a database? Advantages: 1. Views doesn't store data in a physical location. 2. View can be use to hide some of the columns from the table 3. Views can provide Access Restriction, since data insertion , updation and deletion is not possible on the view.

Disadvantages: 1. When a table is dropped , associated view become irrelevant. 2. Since view are created when a query requesting data from view is triggered, its bit slow 3. When views are created for large tables, it occupy more memory .

SQL Interview Questions on Stored Procedures and Triggers


29. What is a stored procedure? Stored Procedure is a function which contain collection of SQL Queries. Procedure can take inputs , process them and send back output.

30. What are the advantages a stored procedure? Stored Procedures are precomplied and stored in database. This enable the database to execute the queries much faster. Since many queries can be included in a stored procedure, round trip time t o execute multiple queries from source code to database and back is avoided.

31. What is a trigger?

Database are set of commands that get executed when an event(Before Insert,After Insert,On Update,On delete of a row) occurs on a table,views.

32. Explain the difference between DELETE , TRUNCATE and DROP commands? Once delete operation is performed Commit and Rollback can be performed to retrieve data. But after truncate statement, Commit and Rollback rollback statement cant be performed. Where condition can be used along with delete statement but it cant be used with truncate statement. Drop command is used to drop the table or keys like primary,foreign from a table.

33. What is the difference between Cluster and Non cluster Index? A clustered index reorders the way records in the table are physically stored. There can be only one clustered index per table. It make data retrieval faster. A non clustered index does not alter the way it was stored but creates a complete separate object within the table. As a result insert and update command will be faster.

34. What is Union, minus and Interact commands? MINUS operator is used to return rows from the first query but not from the second query. INTERSECT operator is used to return rows returned by both the queries.

Frequently asked basic and advanced Top 75 + Database SQL Interview Questions and Answers with Examples, Queries for Freshers and Experienced Java, PHP, .Net Developers in Oracle, MySQL and SQL Server 2008. ForInterview Questions on Advanced queries go to last section of the document. For detailed explanation of SQL functions visit SQL Tutorials. If the answers are same for Oracle, MySQL and SQL databases, only one query is specified. If the SQL Commands differ for Oracle, MySQL and SQL Server, specific queries with respect to a database is provided. Interview Questions on SQL are based on following two tables, Employee Table and Employee Incentive Table.

Table Name : Employee

EMPLOYEE_ID

FIRST_NAME

LAST_NAME

SALARY

JOINING_DATE

DEPARTMENT

Jhon

Abraham

1000000

01-JAN-13 12.00.00 AM

Banking

Michael

Clarke

800000

01-JAN-13 12.00.00 AM

Insurance

Roy

Thomas

700000

01-FEB-13 12.00.00 AM

Banking

Tom

Jose

600000

01-FEB-13 12.00.00 AM

Insurance

Jerry

Pinto

650000

01-FEB-13 12.00.00 AM

Insurance

Philip

Mathew

750000

01-JAN-13 12.00.00 AM

Services

TestName1

123

650000

01-JAN-13 12.00.00 AM

Services

TestName2

Lname%

600000

01-FEB-13 12.00.00 AM

Insurance

Table Name : Incentives

EMPLOYEE_REF_ID

INCENTIVE_DATE

INCENTIVE_AMOUNT

01-FEB-13

5000

01-FEB-13

3000

01-FEB-13

4000

01-JAN-13

4500

01-JAN-13

3500

Database SQL Queries Interview Questions on "SQL Select"


1. Get all employee details from the employee table
Select * from employee

2. Get First_Name,Last_Name from employee table


Select first_name, Last_Name from employee

3. Get First_Name from employee table using alias name Employee Name
Select first_name Employee Name from employee

4. Get First_Name from employee table in upper case


Select upper(FIRST_NAME) from EMPLOYEE

5. Get First_Name from employee table in lower case


Select lower(FIRST_NAME) from EMPLOYEE

6. Get unique DEPARTMENT from employee table


select distinct DEPARTMENT from EMPLOYEE

7. Select first 3 characters of FIRST_NAME from EMPLOYEE Oracle Equivalent of SQL Server SUBSTRING is SUBSTR, Query : select substr(FIRST_NAME,0,3) from employee SQL Server Equivalent of Oracle SUBSTR is SUBSTRING, Query : select substring(FIRST_NAME,0,3) from employee MySQL Server Equivalent of Oracle SUBSTR is SUBSTRING. In MySQL start position is 1, Query :select substring(FIRST_NAME,1,3) from employee 8. Get position of 'o' in name 'Jhon' from employee table
Oracle Equivalent of SQL Server CHARINDEX is INSTR, Query : Select instr(FIRST_NAME,'o') from employee where first_name = 'Jhon' SQL Server Equivalent of Oracle INSTR is CHARINDEX,Query: Select CHARINDEX('o',FIRST_NAME,0) from employee where first_name = 'Jhon' MySQL Server Equivalent of Oracle INSTR is LOCATE, Query: Select LOCATE('o',FIRST_NAME) from employee where first_name = 'Jhon'

9. Get FIRST_NAME from employee table after removing white spaces from right side
select RTRIM(FIRST_NAME) from employee

10. Get FIRST_NAME from employee table after removing white spaces from left side
select LTRIM(FIRST_NAME) from employee

11. Get length of FIRST_NAME from employee table


Oracle,MYSQL Equivalent of SQL Server Len is Length , Query :select length(FIRST_NAME) from employee SQL Server Equivalent of Oracle,MYSQL Length is Len, Query :select len(FIRST_NAME) from employee

12. Get First_Name from employee table after replacing 'o' with '$'
select REPLACE(FIRST_NAME,'o','$') from employee

13. Get First_Name and Last_Name as single column from employee table separated by a '_' Oracle Equivalent of MySQL concat is '||', Query : Select FIRST_NAME|| '_' ||LAST_NAME from EMPLOYEE SQL Server Equivalent of MySQL concat is '+', Query : Select FIRST_NAME + '_' +LAST_NAME from EMPLOYEE MySQL Equivalent of Oracle '||' is concat, Query : Select concat(FIRST_NAME,'_',LAST_NAME) from EMPLOYEE 14. Get FIRST_NAME ,Joining year,Joining Month and Joining Date from employee table SQL Queries in Oracle, Select FIRST_NAME, to_char(joining_date,'YYYY') JoinYear , to_char(joining_date,'Mon'), to_char(joining_date,'dd') from EMPLOYEE SQL Queries in SQL Server, select SUBSTRING (convert(varchar,joining_date,103),7,4) , SUBSTRING (convert(varchar,joining_date,100),1,3) , SUBSTRING (convert(varchar,joining_date,100),5,2) from EMPLOYEE SQL Queries in MySQL, select year(joining_date),month(joining_date), DAY(joining_date) from EMPLOYEE

15. Get all employee details from the employee table order by First_Name Ascending Select * from employee order by FIRST_NAME asc 16. Get all employee details from the employee table order by First_Name descending Select * from employee order by FIRST_NAME desc 17. Get all employee details from the employee table order by First_Name Ascending and Salary descending Select * from employee order by FIRST_NAME asc,SALARY desc

Database SQL Queries Interview Questions on "SQL Where Condition"


18. Get employee details from employee table whose employee name is Jhon Select * from EMPLOYEE where FIRST_NAME = 'Jhon' 19. Get employee details from employee table whose employee name are Jhon and Roy Select * from EMPLOYEE where FIRST_NAME in ('Jhon','Roy') 20. Get employee details from employee table whose employee name are not Jhon and Roy Select * from EMPLOYEE where FIRST_NAME not in ('Jhon','Roy')

Database SQL Queries Interview Questions on "SQL Wild Card"


21. Get employee details from employee table whose first name starts with 'J' Select * from EMPLOYEE where FIRST_NAME like 'J%' 22. Get employee details from employee table whose first name contains 'o' Select * from EMPLOYEE where FIRST_NAME like '%o%' 23. Get employee details from employee table whose first name ends with 'n' Select * from EMPLOYEE where FIRST_NAME like '%n'

Database SQL Queries Interview Questions on "SQL Pattern Matching"


24. Get employee details from employee table whose first name ends with 'n' and name contains 4 letters Select * from EMPLOYEE where FIRST_NAME like '___n' (Underscores) 25. Get employee details from employee table whose first name starts with 'J' and name contains 4 letters Select * from EMPLOYEE where FIRST_NAME like 'J___' (Underscores) 26. Get employee details from employee table whose Salary greater than 600000 Select * from EMPLOYEE where Salary > 600000 27. Get employee details from employee table whose Salary less than 800000 Select * from EMPLOYEE where Salary < 800000 28. Get employee details from employee table whose Salary between 500000 and 800000 Select * from EMPLOYEE where Salary between 500000 and 800000 29. Get employee details from employee table whose name is 'Jhon' and 'Michael' Select * from EMPLOYEE where FIRST_NAME in ('Jhon','Michael')

Database SQL Queries Interview Questions on "SQL DATE Functions"


30. Get employee details from employee table whose joining year is 2013

SQL Queries in Oracle, Select * from EMPLOYEE where to_char(joining_date,'YYYY') = '2013' SQL Queries in SQL Server, Select * from EMPLOYEE where SUBSTRING(convert(varchar,joining_date,103),7,4) = '2013' SQL Queries in MySQL, Select * from EMPLOYEE where year(joining_date) = '2013' 31. Get employee details from employee table whose joining month is January SQL Queries in Oracle, Select * from EMPLOYEE where to_char(joining_date,'MM') = '01' or Select * from EMPLOYEE where to_char(joining_date,'Mon') = 'Jan' SQL Queries in SQL Server, Select * from EMPLOYEE where SUBSTRING(convert(varchar,joining_date,100),1,3) = 'Jan' SQL Queries in MySQL, Select * from EMPLOYEE where month(joining_date) = '01' 32. Get employee details from employee table who joined before January 1st 2013 SQL Queries in Oracle, Select * from EMPLOYEE where JOINING_DATE < to_date('01/01/2013','dd/mm/yyyy') SQL Queries in SQL Server (Format - MM/DD/YYYY), Select * from EMPLOYEE where joining_date < '01/01/2013' SQL Queries in MySQL (Format - YYYY-DD-MM), Select * from EMPLOYEE where joining_date < '2013-01-01' 33. Get employee details from employee table who joined after January 31st SQL Queries in Oracle, Select * from EMPLOYEE where JOINING_DATE > to_date('31/01/2013','dd/mm/yyyy') SQL Queries in SQL Server and MySQL (Format - MM/DD/YYYY), Select * from EMPLOYEE where joining_date >'01/31/2013' SQL Queries in MySQL (Format - YYYY-DD-MM), Select * from EMPLOYEE where joining_date >'2013-01-31' 34. Get employee details from employee table who joined between January 1st and January 31st SQL Queries in Oracle, Select * from EMPLOYEE where JOINING_DATE between to_date('01/01/2013','dd/mm/yyyy') and to_date('31/01/2013','dd/mm/yyyy') SQL Queries in SQL Server (Format - MM/DD/YYYY), Select * from EMPLOYEE where joining_date between '01/01/2013' and '01/31/2013'

SQL Queries in MySQL (Format - YYYY-DD-MM), Select * from EMPLOYEE where joining_date between '2013-01-01' and '2013-01-31' 35. Get Joining Date and Time from employee table SQL Queries in Oracle, select to_char(JOINING_DATE,'dd/mm/yyyy hh:mi:ss') from EMPLOYEE SQL Queries in SQL Server, Select convert(varchar(19),joining_date,121) from EMPLOYEE SQL Queries in MySQL, Select CONVERT(DATE_FORMAT(joining_date,'%Y-%m-%d%H:%i:00'),DATETIME) from EMPLOYEE 36. Get Joining Date,Time including milliseconds from employee table SQL Queries in Oracle, select to_char(JOINING_DATE,'dd/mm/yyyy HH:mi:ss.ff') from EMPLOYEE . Column Data Type should be TimeStamp SQL Queries in SQL Server, select convert(varchar,joining_date,121) from EMPLOYEE SQL Queries in MySQL, Select MICROSECOND(joining_date) from EMPLOYEE 37. Get difference between JOINING_DATE and INCENTIVE_DATE from employee and incentives table Select FIRST_NAME,INCENTIVE_DATE - JOINING_DATE from employee a inner join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID 38. Get database date SQL Queries in Oracle, select sysdate from dual SQL Queries in SQL Server, select getdate() SQL Query in MySQL, select now()

Database SQL Queries Interview Questions on "SQL Escape Characters"


39. Get names of employees from employee table who has '%' in Last_Name. Tip : Escape character for special characters in a query. SQL Queries in Oracle, Select FIRST_NAME from employee where Last_Name like '%?%%' SQL Queries in SQL Server, Select FIRST_NAME from employee where Last_Name like '%[%]%'

SQL Queries in MySQL,Select FIRST_NAME from employee where Last_Name like '%\%%' 40. Get Last Name from employee table after replacing special character with white space SQL Queries in Oracle, Select translate(LAST_NAME,'%',' ') from employee SQL Queries in SQL Server adn MySQL, Select REPLACE(LAST_NAME,'%',' ') from employee

Database SQL Queries Interview Questions on "SQL Group By Functions"


41. Get department,total salary with respect to a department from employee table. Select DEPARTMENT,sum(SALARY) Total_Salary from employee group by department 42. Get department,total salary with respect to a department from employee table order by total salary descending Select DEPARTMENT,sum(SALARY) Total_Salary from employee group by DEPARTMENT order by Total_Salary descending

Database SQL Queries Interview Questions on "SQL Mathematical Operations and Group By"
43. Get department,no of employees in a department,total salary with respect to a department from employee table order by total salary descending Select DEPARTMENT,count(FIRST_NAME),sum(SALARY) Total_Salary from employee group by DEPARTMENT order by Total_Salary descending 44. Get department wise average salary from employee table order by salary ascending select DEPARTMENT,avg(SALARY) AvgSalary from employee group by DEPARTMENT order by AvgSalary asc 45. Get department wise maximum salary from employee table order by salary ascending select DEPARTMENT,max(SALARY) MaxSalary from employee group by DEPARTMENT order by MaxSalary asc 46. Get department wise minimum salary from employee table order by salary ascending select DEPARTMENT,min(SALARY) MinSalary from employee group by DEPARTMENT order by MinSalary asc 47. Select no of employees joined with respect to year and month from employee table

SQL Queries in Oracle, select to_char (JOINING_DATE,'YYYY') Join_Year,to_char (JOINING_DATE,'MM') Join_Month,count(*) Total_Emp from employee group by to_char (JOINING_DATE,'YYYY'),to_char(JOINING_DATE,'MM') SQL Queries in SQL Server, select datepart (YYYY,JOINING_DATE) Join_Year,datepart (MM,JOINING_DATE) Join_Month,count(*) Total_Emp from employee group by datepart(YYYY,JOINING_DATE), datepart(MM,JOINING_DATE) SQL Queries in MySQL, select year (JOINING_DATE) Join_Year,month (JOINING_DATE) Join_Month,count(*) Total_Emp from employee group by year(JOINING_DATE), month(JOINING_DATE) 48. Select department,total salary with respect to a department from employee table where total salary greater than 800000 order by Total_Salary descinding Select DEPARTMENT,sum(SALARY) Total_Salary from employee group by DEPARTMENT having sum(SALARY) > 800000 order by Total_Salary desc

49. Select first_name, incentive amount from employee and incentives table for those employees who have incentives Select FIRST_NAME,INCENTIVE_AMOUNT from employee a inner join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID 50. Select first_name, incentive amount from employee and incentives table for those employees who have incentives and incentive amount greater than 3000 Select FIRST_NAME,INCENTIVE_AMOUNT from employee a inner join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID and INCENTIVE_AMOUNT > 3000 51. Select first_name, incentive amount from employee and incentives table for all employess even if they didn't get incentives Select FIRST_NAME,INCENTIVE_AMOUNT from employee a left join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID 52. Select first_name, incentive amount from employee and incentives table for all employees even if they didn't get incentives and set incentive amount as 0 for those employees who didn't get incentives. SQL Queries in Oracle, Select FIRST_NAME,nvl(INCENTIVE_AMOUNT,0) from employee a left join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID SQL Queries in SQL Server, Select FIRST_NAME, ISNULL(INCENTIVE_AMOUNT,0) from employee a left join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID

SQL Queries in MySQL, Select FIRST_NAME, IFNULL(INCENTIVE_AMOUNT,0) from employee a left join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID 53. Select first_name, incentive amount from employee and incentives table for all employees who got incentives using left join SQL Queries in Oracle, Select FIRST_NAME,nvl(INCENTIVE_AMOUNT,0) from employee a right join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID SQL Queries in SQL Server, Select FIRST_NAME, isnull(INCENTIVE_AMOUNT,0) from employee a right join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID SQL Queries in MySQL, Select FIRST_NAME, IFNULL(INCENTIVE_AMOUNT,0) from employee a right join incentives B on A.EMPLOYEE_ID = B.EMPLOYEE_REF_ID 54. Select max incentive with respect to employee from employee and incentives table using sub query SQL Queries in Oracle, select DEPARTMENT,(select nvl(max(INCENTIVE_AMOUNT),0) from INCENTIVES where EMPLOYEE_REF_ID = EMPLOYEE_ID) Max_incentive from EMPLOYEE SQL Queries in SQL Server, select DEPARTMENT,(select ISNULL(max(INCENTIVE_AMOUNT),0) from INCENTIVES where EMPLOYEE_REF_ID = EMPLOYEE_ID) Max_incentive from EMPLOYEE SQL Queries in SQL Server, select DEPARTMENT,(selectIFNULL (max(INCENTIVE_AMOUNT),0) from INCENTIVES where EMPLOYEE_REF_ID = EMPLOYEE_ID) Max_incentive from EMPLOYEE

Database SQL Queries Interview Questions on "Top N Salary"


55. Select TOP 2 salary from employee table SQL Queries in Oracle, select * from (select * from employee order by SALARY desc) where rownum < 3 SQL Queries in SQL Server, select top 2 * from employee order by salary desc SQL Queries in MySQL, select * from employee order by salary desc limit 2 56. Select TOP N salary from employee table SQL Queries in Oracle, select * from (select * from employee order by SALARY desc) where rownum < N + 1 SQL Queries in SQL Server, select top N * from employee SQL Queries in MySQL, select * from employee order by salary desc limit N

57. Select 2nd Highest salary from employee table SQL Queries in Oracle, select min(salary) from (select * from (select * from employee order by SALARY desc) where rownum < 3) SQL Queries in SQL Server, select min(SALARY) from (select top 2 * from employee) a SQL Queries in MySQL, select min(SALARY) from (select * from employee order by salary desc limit 2) a 58. Select Nth Highest salary from employee table SQL Queries in Oracle, select min(salary) from (select * from (select * from employee order by SALARY desc) where rownum < N + 1) SQL Queries in SQL Server, select min(SALARY) from (select top N * from employee) a SQL Queries in MySQL, select min(SALARY) from (select * from employee order by salary desc limit N) a

Database SQL Queries Interview Questions on "SQL Union"


59. Select First_Name,LAST_NAME from employee table as separate rows select FIRST_NAME from EMPLOYEE union select LAST_NAME from EMPLOYEE 60. Select employee details from employee table if data exists in incentive table select * from EMPLOYEE where exists (select * from INCENTIVES)

Database Queries Interview Questions on "SQL Advanced Queries"


61. Select 20 % of salary from Jhon , 10% of Salary for roy and for other 15 % of salary from employee table SELECT FIRST_NAME, CASE FIRST_NAME WHEN 'Jhon' THEN SALARY * .2 WHEN 'Roy' THEN SALARY * .10 ELSE SALARY * .15 END "Deduced_Amount" FROM EMPLOYEE 62. Select Banking as 'Bank Dept', Insurance as 'Insurance Dept' and Services as 'Services Dept' from employee table SQL Queries in Oracle, SELECT distinct DECODE (DEPARTMENT, 'Banking', 'Bank Dept', 'Insurance', 'Insurance Dept', 'Services', 'Services Dept') FROM EMPLOYEE SQL Queries in SQL Server and MySQL, SELECT case DEPARTMENT when 'Banking' then 'Bank Dept' when 'Insurance' then 'Insurance Dept' when 'Services' then 'Services Dept' end FROM EMPLOYEE

63. Delete employee data from employee table who got incentives in incentive table delete from EMPLOYEE where EMPLOYEE_ID in (select EMPLOYEE_REF_ID from INCENTIVES) 64. Insert into employee table Last Name with ''' (Single Quote - Special Character, Use single quote before special character ) Insert into employee (LAST_NAME) values ('Test''') 65. Select Last Name from employee table which contain only numbers Select * from EMPLOYEE where lower(LAST_NAME) = upper(LAST_NAME)

Database SQL Queries Interview Questions on "SQL Table Scripts"


66. Write create table syntax for employee table Oracle CREATE TABLE EMPLOYEE ( EMPLOYEE_ID NUMBER, FIRST_NAME VARCHAR2(20 BYTE), LAST_NAME VARCHAR2(20 BYTE), SALARY FLOAT(126), JOINING_DATE TIMESTAMP (6) DEFAULT sysdate, DEPARTMENT VARCHAR2(30 BYTE) ) SQL Server CREATE TABLE EMPLOYEE( EMPLOYEE_ID int NOT NULL, FIRST_NAME varchar(50) NULL, LAST_NAME varchar(50) NULL, SALARY decimal(18, 0) NULL, JOINING_DATE datetime2(7) default getdate(), DEPARTMENT varchar(50) NULL) 67. Write syntax to delete table employee DROP table employee; 68. Write syntax to set EMPLOYEE_ID as primary key in employee table ALTER TABLE EMPLOYEE add CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EMPLOYEE_ID)

69. Write syntax to set 2 fields(EMPLOYEE_ID,FIRST_NAME) as primary key in employee table ALTER TABLE EMPLOYEE add CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EMPLOYEE_ID,FIRST_NAME) 70. Write syntax to drop primary key on employee table Alter TABLE EMPLOYEE drop CONSTRAINT EMPLOYEE_PK; 71. Write Sql Syntax to create EMPLOYEE_REF_ID in INCENTIVES table as foreign key with respect to EMPLOYEE_ID in employee table ALTER TABLE INCENTIVES ADD CONSTRAINT INCENTIVES_FK FOREIGN KEY (EMPLOYEE_REF_ID) REFERENCES EMPLOYEE(EMPLOYEE_ID) 72. Write SQL to drop foreign key on employee table ALTER TABLE INCENTIVES drop CONSTRAINT INCENTIVES_FK; 73. Write SQL to create Orcale Sequence CREATE SEQUENCE EMPLOYEE_ID_SEQ START WITH 0 NOMAXVALUE MINVALUE 0 NOCYCLE NOCACHE NOORDER; 74. Write Sql syntax to create Oracle Trigger before insert of each row in employee table CREATE OR REPLACE TRIGGER EMPLOYEE_ROW_ID_TRIGGER BEFORE INSERT ON EMPLOYEE FOR EACH ROW DECLARE seq_no number(12); BEGIN select EMPLOYEE_ID_SEQ.nextval into seq_no from dual ; :new EMPLOYEE_ID := seq_no; END; SHOW ERRORS;

SQL Joins
In order to avoid data duplication , data is stored in related tables . Join keyword is used to fetch data from related table. Type of joins are

Join Outer Join Left Join

Full Join

SQL Join query with examples on Employee and Salary table given below are

JOIN
Return rows when there is at least one match in both tables . SQL query to join above tables are as given below

select * from employee a join salary b on a.employee_id = b.employee_id_ref

SQL Query output is as shown below

Left JOIN
Return all rows from the left table, even if there are no matches in the right table . SQL query to left join above tables are as given below

select * from employee a left join salary b on a.employee_id = b.employee_id_ref


SQL Query output is as shown below

Right JOIN
Return all rows from the right table, even if there are no matches in the left table . SQL query to right join above tables are as given below

select * from employee a right join salary b on a.employee_id = b.employee_id_ref


SQL Query output is as shown below

Full JOIN
Return rows when there is a match in one of the tables . SQL query to full join above tables are as given below

select * from employee a full join salary b on a.employee_id = b.employee_id_ref


SQL Query output is as shown below

Same set of queries are applicable for databases like MYSQL | Oracle | SQL Server . Hope these examples will help you in writing SQL Query better .

SQL Queries Examples for Like Command


SQL Like Query For wildcard filtering Like operator is used . Within a search string, % means match any number of occurrences of any character. For example , to fetch all names starting with letter J from employee table given below following SQL query is used .

select * from employee where employee_name like 'J%'


SQL Query output is given below

To fetch all names containing letter a , following SQL query is used .

select * from employee where employee_name like '%a%'


SQL Query output is given below .

To fetch all names ending with letter y , following SQL query is used .

select * from employee where employee_name like '%y'


SQL Query output is given below .

Points to be noted before using Like Operator SQL 'Like' search takes more time to process . So before using like operator following tips should be considerd .

Don't overuse wildcards. If another search operator will do, use it instead. When you do use wildcards, try to not use them at the beginning of the search pattern unless absolutely necessary. Search patterns that begin with wildcards are the slowest to process. Pay careful attention to the placement of the wildcard symbols. If they are misplaced, you might not return the data you intended Same set of queries are applicable for databases like MYSQL | Oracle | SQL Server . Hope these examples will help you in writing SQL Query better .

SQL Queries Examples for Where,IN,AND,OR and Between Operator


SQL Where Clause

SQL where clause is used to retrieve subset of table's data using filter conditions . SQL Where clause is specified after table name . For example, To retrieve a row from the table specified below , following SQL query is used .

Select * from Employee where employee_id = 2 , SQL Query output is given below

Following where clause operators can be used in SQL .

> greater than operator

Select * from Employee where employee_id > 2


SQL Query output is given below

>= greater than or equal to operator

Select * from Employee where employee_id >= 2, SQL Query output is given below

< less than operator

Select * from Employee where employee_id < 2,SQL Query output is given below

<= less than or equal to operator

Select * from Employee where employee_id <= 2 ,SQL Query output is given below

< > or != not equal operator

Select * from Employee where employee_id < >2 or Select * from Employee where employee_id != 2

SQL Query output is given below

SQL Between
between between two values operator

Select * from Employee where employee_id between 2 and 4 , SQL Query output is given below

SQL Null
Null keyword is used to fetch data from table where a columns values in NULL select * from employee where age is null

Advanced Filtering ( And & OR ) AND Keyword

To filter by more than one column, use AND operator to append conditions to WHERE clause

select * from employee where employee_name = 'Alex' and age > 20


SQL Query output is given below

OR Keyword
The OR operator instructs the database management system software to retrieve rows that match either condition.

select * from employee where employee_name ='Alex' or age > 40


SQL Query output is given below

Using And and OR Keyword with parenthesis

select * from employee where (employee_name ='Alex' or employee_name ='Roy' ) and age > 20
SQL Query output is given below

SQL IN Operator
The IN operator is used to specify a range of conditions, any of which can be matched.

select * from employee where employee_name in ('Alex','Roy' )


SQL Query output is given below

SQL NOT

The NOT operator is used to fetch data from table where condition is not matched select * from employee where employee_name not in ('Alex','Roy' ) Same set of queries are applicable for databases like MYSQL | Oracle | SQL Server . Hope these examples will help you in writing SQL Query better .

SQL Queries Examples for Group By Command


SQL Group By Clause SQL Group by Clause is used to find sum, max , min , count belonging to a particular category . For example ,to get total salary of employees from the Salary table given below

Following SQL query is used .

select employee_name,Sum(salary) Salary from salary group by employee_name


SQL Output is given below

Same set of queries are applicable for databases like MYSQL | Oracle | SQL Server . Hope these examples will help you in writing SQL Query better .

Largest Sum Of Contiguous Subarray


Time Complexity: O(n) Algorithmic Paradigm: Dynamic Programming

Find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum. For example if the given array is [ 12, 14, 0, -4, 61, -39 ], then the answer is 83.

Solution This is a well known problem commonly known as Maximum Subarray Problem and can be solved using Kadane's algorithm in O(n).

The whole logic of algorithm is to iterate each element of the array and find the maximum subarray at each position. So at any position, either the max array will be empty ( if the subarray calculated till then becomes less than or equals to zero) or it may contain one more element more than the maximum subarray at previous location ( if the subarray calculated till then has sum greater than 0).

This algorithm keeps two variables, 'max_so_far' and 'max_ending_here'. 'max_so_far' keeps the maximum subarray calculated till previous step. 'max_ending_here' is used to keep on adding the values of array elements. Algorithm 1. 2. 3. Set max_so_far = 0; Set max_ending_here = 0; from i = 0 to length of array

o o o
4.

max_ending_here = max_ending_here + array[i] If max_ending_here < 0, max_ending_here = 0 If max_so_far < max_ending_here max_so_far = max_ending_here

return max_so_far Find the Java Code below

public int calculateMaxArray(int[] array){ int max_so_far = 0; int max_ending_here = 0;

for(int i = 1; i < array.length; i++){ max_ending_here += array[i]; if( max_ending_here < 0 max_ending_here = 0; } ){

if( max_so_far < max_ending_here){ max_so_far = max_ending_here; } } return max_so_far; }

Detecting Loop In Linkedlist - Hare And Tortoise Algorithm or Floyd Cycle Detection Algorithm
Floyd's cycle detection algorithm, also known as Tortoise And Hare algorithms, is used to detect loop in sequence of iterated function values. We can use this algorithm to detect loop or cycle in a singly linked list.

This algorithm makes use of two pointers. The concept of algorithm is that if the two pointers to the linked list are iterating over the list at different speeds, they will meet at some point if a loop exists in the list.

Consider two pointers, P1 andP2. If P1 is moving at twice the speed of P2, they will meet at the start of next lap.

Now from this meeting point, if we move one of the pointers back to the start of list and start moving both the pointers at same speed, they will meet again at the start of the loop.

Algorithm for finding cycle in Linkedlist


hare = first tortoise = first while( hare.next != null ){ hare = hare.next.next tortoise = tortoise.next if( hare == tortoise ){ break } } if( hare.next == null){ return null } tortoise = first while( hare != tortoise ){ hare = hare.next tortoise = tortoise.next

} return hare

Tree Traversal Without Recursion Iterative Tree Traversal


Its a famous problem which many people wher asked in technical interviews especially in companies like Amazon, Subex etc to write algorithm to traverse a binary tree without recursion, traverse iteratively. This algorithm uses a stack to traverse the tree instead of the recursion ( There is version which traverses without using even stack and recursion, by using threaded trees. We will discuss it later).

Fig : 1 Here we will discuss all the three inorder, preorder and postorder traversal.

Pre order traversal without recursion is the simplest one. Post order traversal without recursion is the complex one since there we need to remember which node visited previously (in post order traversal node it processed at the end after processing its left and right children).

We will use the above image to describe there traversal.

Preorder Traversal Without Recursion Iterative Preorder Traversal


Algorithm for preorder traversal without recursion is the simplest iterative traversal algorithm and its strait forward. If do inorder traversal on the tree given, result would be 1, 2, 4, 5, 3. Find the algorithm below.

Preorder Traversal
Process: Create a stack with only root node in the stack. Then in the loop, pop the top element off the stack, process (print) it. Push its left and right children to the stack if it has any.

Algorithm

create an empty stack push root into stack

while ( stack is not empty ){ tmpNode = stack.pop() print tmpNode.value if( tmpNode.rightChild != null){ stack.push(tmpNode.rightChild) } if( tmpNode.leftChild != null){ stack.push(tmpNode.leftChild) }

Example Consider the given tree,

Initial Stage
stack = [1]

Loop 1 :
console output : 1 stack = [ 2, 3]

Loop 2 :
console output : 1, 2 stack = [ 4, 3]

Loop 3 :
console output : 1, 2, 4 stack = [ 5, 3]

Loop 4 :
console output : 1, 2, 4, 5 stack = [ 3]

Loop 5 :
console output : 1, 2, 4, 5, 3 stack = [ ]

Inorder Traversal Without Recursion Iterative Inorder Tree Traversal


In case of inorder tree traversal first a nodes left child is processed, then the actual node then its right node. If do inorder traversal on the tree given, result would be 4, 2, 5, 1, 3. To do this operations iteratively, we have to use a stack to simulate effect of recursion.

Inorder Traversal Process : Initialize current_node as the root node. Then push current_node and all the subsequent left nodes are pushed on to the stack. When current node becomes null, its meaning is that one complete left path is finished, ie; previous node (which ever is on top of the stack) was an unprocessed left most node. Then pop and print this node, and set current node as the right node of the node jus popped of the stack.

Algorithm

set current_node = root set stack as empty while( true ){ if( current_node == null and stack is empty ){ return }else if( current_node == null ){ tmpNode = stack.pop print tmpNode current_node = tmpNode.right }else{ stack.push(current_node) current_node = current_node.left } }
Example We will analyse the algorithm using Fig:1.

Initial Stage
current_node : 1 stack : [ ]
In first loop, control goes to last else statement and continues till the left most leaf (4).

Loop 1 :

current_node : 2 stack : [ 1 ] console output :

Loop 2 :

current_node : 4 stack : [ 2, 1 ] console output :

Loop 3 :

current_node : null stack : [ 4, 2, 1 ] console output :

In the next loop, current_node is null, so second if condition satisfies and it pops the top element of the stack

Loop 4 :

current_node : null ( right child of 4) stack : [ 2, 1 ] console output : 4

Loop 5 : current_node : 5 ( right child of 2) stack : [ 1 ] console output : 4 2

Loop 6 : current_node : null ( left child of 5) stack : [ 5, 1 ] console output : 4 2

Loop 7 : current_node : null ( right child of 5) stack : [ 1 ] console output : 4 2 5

Loop 8 :

current_node : null ( right child of 1) stack : [ 1 ] console output : 4 2 5 1

This continues and the final console output will be : 4 2 5 1 3

You might also like