You are on page 1of 12

Sql Server Which of the following is not an aggregate function in SQL Server 2005?

(a) Min (b) Group (c) SUM (d) COUNT How many clustered indexes can be created on single table? (a) 1 (b) 128 (c) 256 (d) Upto number of columns in table If we want to store true or false(yes/no) in SQL fetching values from my frontend which datatype should We use at the best level in terms of minimum storage? (a) (b) (c) (d) Char Varchar Bit Int

Which clause returns only one copy of each set of duplicate rows selected? (a) (b) (c) (d) Unique Group by Distinct None of the above

Which operator is used in character string comparisons with patter matching? (a) (b) (c) (d) Like Between And Equal operator Set Operator

You want to make data in the SSN column in a table unique. Howerver, you want to the column to be able to accept only one NULL value if needed. Which of the following constraint would you use to implement the solution? (a) (b) (c) (d) Primary Key constraint Unique constraint Foreign Key constraint Default constraint

1. What is RDBMS? Answer 1:

Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.
2. What are different normal forms? Answer2:

1NF: Eliminate Repeating Groups Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain. 2NF: Eliminate Redundant Data If an attribute depends on only part of a multi-valued key, remove it to a separate table. 3NF: Eliminate Columns Not Dependent On Key If attributes do not contribute to a description of the key, remove them to a separate table. All attributes must be directly dependent on the primary key BCNF: Boyce-Codd Normal Form If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables. 4NF: Isolate Independent Multiple Relationships No table may contain two or more 1:n or n:m relationships that are not directly related. 5NF: Isolate Semantically Related Multiple Relationships There may be practical constrains on information that justify separating logically related many-tomany relationships.

3. Advantages of Normalization? Answer3: 1) Avoids data modification (INSERT/DELETE/UPDATE) anomalies as each data item lives in One place 2) Greater flexibility in getting the expected data in atomic granular 3) Normalization is conceptually cleaner and easier to maintain and change as your needs change 4) Fewer null values and less opportunity for inconsistency 5) A better handle on database security

6) Increased storage efficiency 7) The normalization process helps maximize the use of clustered indexes, which is the most powerful and useful type of index available. 4. Explain view with one example? Answer4: Creates a virtual table whose contents (columns and rows) are defined by a query. Use this statement to create a view of the data in one or more tables in the database. For example, a view can be used for the following purposes: To focus, simplify, and customize the perception each user has of the database. As a security mechanism by allowing users to access data through the view, without granting the users permissions to directly access the underlying base tables. To provide a backward compatible interface to emulate a table whose schema has changed.

5. Difference between function and stored procedures? Answer5: Functions ---------1) can be used with Select statement 2) Not returning output parameter but returns Table variables 3) You can join UDF 4) Cannot be used to change server configuration 5) Cannot be used with XML FOR clause 6) Cannot have transaction within function Stored Procedure ----------------1) have to use EXEC or EXECUTE 2) return output parameter 3) can create table but wont return Table Variables 4) you can not join SP 5) can be used to change server configuration 6) can be used with XML FOR Clause 7) can have transaction within SP 6. What is view? 7. What is the difference between clustered and non-clustered index? Answer 7: (i) The difference is that, Clustered index is unique for any given table and we can have only one clustered index on a table. (ii) The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index. (i) Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db.

8. Why we use Cursor and how to create cursor? Answer8: We want to perform operation row by row. That time we use cursor. Example
DECLARE db_cursor CURSOR FOR SELECT name FROM Employee HERE empID IN (1001,1002,1003) OPEN db_cursor FETCH NEXT FROM db_cursor INTO @name WHILE @@FETCH_STATUS = 0 BEGIN print @name FETCH NEXT FROM db_cursor INTO @name END CLOSE db_cursor DEALLOCATE db_cursor

9. What is difference between Primary, Unique and foreign Key? Answer9: Primary Key: It will not allow "Null values" and "Duplicate values" Unique Key: Unique key constraint is used to prevent the duplication of key values within the rows of a table and allow null values Foreign Key: It will allow "Null values" and "Duplicte values" and it refers to a primary key in anoter table. 10. What is difference between Truncate and Delete and give the one example of both? Answer10 TRUNCATE is a DDL (data definition language) command whereas DELETE is a DML (data manipulation language) command. TRUNCATE TABLE always locks the table and page but not each row whereas DELETE statement is executed using a row lock, each row in the table is locked for deletion. You can use WHERE clause(conditions) with DELETE but you can't use WHERE clause with TRUNCATE . You cant rollback data in TRUNCATE but in DELETE you can rollback data. TRUNCATE removes(delete) the record permanently. A trigger doesnt get fired in case of TRUNCATE whereas Triggers get fired in DELETE command. If tables which are referenced by one or more FOREIGN KEY constraints then TRUNCATE will not work. TRUNCATE resets the Identity counter if there is any identity column present in the table where delete not resets the identity counter.

Delete and Truncate both are logged operation.But DELETE is a logged operation on a per row basis and TRUNCATE logs the deallocation of the data pages in which the data exists. TRUNCATE is faster than DELETE.

11. What type of joining in Sql server and explain ? Answer 11: Types of Join are : 1.Self Join 2.Inner Join 3.Outer Join 3.1. Right Outer Join 3.2. Left Outer Join 3.3 Full Outer Join 4.Cross join Department Table 12. Why we use HAVING CLAUSE ? Answer 12:

HAVING clause is used to make condition on GROUP BY data and suppose to be used after GROUP BY clause.
13. What is Identity keyword in Sql Server? Answer13:

The IDENTITY columns are auto incrementing columns provided by SQL Server. There can only be one IDENTITY column per table
14. How to insert data from existing table data to another table? Answer 14: INSERT Table2 SELECT * FROM Existingtable WHERE [Conditions] 15. What is trigger? Answer 15:
A trigger is a special kind of a store procedure that executes in response to certain action on the table like insertion, deletion or updation of data. It is a database object which is bound to a table and is executed automatically. we cant explicitly invoke triggers. The only way to do this is by performing the required action no the table that they are assigned to.

16. Advantages of SQL Server Agent? Answer 16: There are many type of services in SQL Server Agent. (i) Job Scheduling (ii) Database messages (iii) Error Logs (iv) Alerts 17. What is difference between .LDF and .MDF file in sql server? Answer 17: .mdf is the primary data file of a SQL database. .ldf is the transaction log file of a SQL database

18. What is difference between INNER JOIN and EXISTS keyword in sql server? Answer 18: Exists: Returns true if a subquery contains any rows. Join: Joins 2 resultsets on the joining column. 19. If we have two table Emp_Details and Salary. Emp_Details Emp_ID 1001 1002 1003 1004 Emp_Name King Fay John A.J. Hoge Address US US UK San Francisco Salary Emp_ID 1001 1005 1007 1004 1010 1009 Sal $500 $405 $543 $853 $2903 $9322

How many rows will be got, if we join both tables? Write only number of rows. (i) (ii) (iii) (iv) Inner Join Left Join Right Join Cross Join

Answer 19: (i) (ii) (iii) (iv) 2 4 6 24

20. Manage the order of query. a. FROM b. ORDER BY c. SELECT d. GROUP BY e. WHERE f. HAVING Answer 20: c, a, e, d, f, b 21. Write the syntax of INSERT Command? Answer 21: Insert into tableName (columnNames) values(columnVales)

22. How to get maximum of 5 salary? Answer 22; Select top 1 Salary from SalaryTable where Salary=(select distinct top 5 salary from SalaryTable order by Salary desc) 23. Write at least three most frequently use Aggregate Function? Answer 23: Sum, Min and Max

th

Asp.Net What is the last stage of the Web forms lifecycle? (a) Event Handling (b) Page_Load (c) Validate (d) Page_Unload (e) Page_Ini

Which is the default authentication method when you create a new web application project? (a) Windows authentication (b) Windows (c) Passport

Which event causes the web page to be sent back to the server for immediate processing? (a) Postback Event (b) Cached Event (c) Validation Event

What is form authentication? (a) Identifies and authorizes users based on the servers user list (b) Allows to create your own database of users and validates the identity of those users when they visit your web site (c) Uses the Microsoft centralized authentication provider to identify users

For read_forward data retrieval, which one is faster?


(a) (b)

Dataset SqlDataReader

How does Asp.Net store Session ID by default? (a) (b) (c) (d) Cache Cookies A global variable URL String or in a database

Security is very important on any web site. By default, a .Net web site is configured with which of the following authentication type? (a) Anonymous

(b) (c) (d) (e)

Basic Digest Windows Authentication Answer a & d

Do we need IIS to develop a web application in ASP.Net 2.0 or above? (a) Yes (b) No

Name a property common in every validation control? (a) (b) (c) (d) (e) ValueToCompare ControlToValidate InitialValue ValidationExpression ControlToCompare

What DataType is return in IsPostback property? (a) (b) (c) (d) Bit Boolean Int Object

Q 1. Write five controls name of asp.net? Answer:1 (i) (ii) (iii) (iv) (v) (vi) Textbox DropdownList Button Checkbox Label Table

Q2. What is an IL in .Net? Answer2: (IL)Intermediate

Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In- Time (JIT) compiler.

Q3. What is the concept of Boxing & Unboxing? Answer3:

Boxing: Converting value type to Reference type is called Boxing. example: Int32 x = 10; object o = x ; // Implicit boxing Console.WriteLine("The Object o = {0}",o); // prints out 10 UnBoxing:Converting Reference type to Value Type is called unboxing. example: Int32 x = 5; object o = x; // Implicit Boxing x = o; // Implicit UnBoxing

Q4. What is the FindControl method? Answer4: We want to find any control from form or any container. That time we use Findcontrol Method. Example : We want to find control from Page. We write below syntax DropdownList myboj =(DropdownList) Page.FindControl(ControlName);

Q5. Why we use Master Page? Answer5: 1. They allow you to centralize the common functionality of your pages so that you can make updates in just one place. 2. They make it easy to create one set of controls and code and apply the results to a set of pages. For example, you can use controls on the master page to create a menu that applies to all pages. 3. They give you fine-grained control over the layout of the final page by allowing you to control how the placeholder controls are rendered. 4. They provide an object model that allows you to customize the master page from individual content pages. Q6. Advantages of CSS? Answe6: The advantages of using CSS include: more precise formatting, separation of HTML content from appearance, saves time, easier site maintenance, and web accessibility.

Q7. We want to connect our asp.net form with Database. What connection string we will be used? Answer7: data source=localhost;initial catalog=IdeaPortal;user id=sa;password=12345 or server= localhost; database= IdeaPortal;uid=sa;pwd=12345

Q8. Define the 3-Tier architecture and advantages? Answer8: 3-Tier Archtechture There are 3 layer for development. (i) (ii) (iii) Presentation Layer: for user view Business Access Layer: for business logic (set validations and rules) Data Access Layer: for database

Different-2 user can work parallel on different layer.


3-Tier Architecture provides the following benefits.

ScalabilityEach tier can scale horizontally. For example, you can load-balance the Presentation tier among 3 servers to satisfy more Web requests without adding servers to the Application and Data tiers. PerformanceBecause the Presentation tier can cache requests, network utilization is minimized, and the load is reduced on the Application and Data tiers. If needed, you can load-balance any tier. AvailabilityIf the Application tier server is down and caching is sufficient, the Presentation tier can process Web requests using the cache.

Q9. How to maintain session in asp.net? Answer 9: (i) (ii) Cookies: It is store in Client Side. Session: It is store in server side. Session life time depends on browser.

Q10. How do you upload file in asp.net? Answer10: Fileupload1.SaveAs(filepath); Q11. What is difference between Cookies and Session? Asnwer 11: Cookies 1. Cookies can store only "string" datatype 2. They are stored at Client side 3. Cookie is non-secure since stored in text format at client side 4. Cookies may or may not be individual for every client 5. Due to cookies network traffic will increase. Size of cookie is limited to 40 and number of cookies to be used is restricted to 20. 6. Only in few situations we can use cookies because of no security 7. We can disable cookies 8. Since the value is string there is no security 9. We have persistent and non-persistent cookies

Session 1 Session can store any type of data because the value is of datatype of "object" 2. These are stored at Server side 3. Session are secure because it is stored in binary format/encrypted form and it gets decrypted at server 4. Session is independent for every client i.e individual for every client 5. There is no limitation on size or number of sessions to be used in an application 6. For all conditions/situations we can use sessions 7. we cannot disable the sessions. Sessions can be used without cookies also(by disabling cookies) 8. The disadvantage of session is that it is a burden/overhead on server 9. Sessions are called as Non-Persistent cookies because its life time can be set manually

Q12 What is difference between Dataset and SqlDataReader? Answer12: The two main points you need to keep in mind about SqlDataReader are: It represents the fastest method available to read data from the data source. It allows read-only, forward-only access to data." DataSets are read/write and we can also move forwards and backwards through them