Thursday 24 November 2016

ADO Test

ADO.Net

  1. What is ADO Full form?

  2. Active Dependency Object
    Active Data Option
    ActiveX Data Object

  3. Which Namespace is needed to work with SqlServer?

  4. Using System.Data;
    Using System.Data.Sql;
    Using System.Data.SqlClient;

  5. What is DataSet?

  6. DataSet is collection of Database
    DataSet is colection of tables
    DataSet is will get data from database

  7. Which statement is TRUE?

  8. Dataset work with Disconnected Architecture
    DatReader work with Disconnected Architecture
    DataAdapter work with connected Architecture

  9. What is the purpose of Ado.Net?

  10. Ado.net is used to create classes in c#
    Ado.net is used to communicate with Database
    Ado.Net is used to create create object of classes

  11. which statemetn is false?

  12. data adapter is meadiator between dataset and database
    data set is not a collection of tables
    None

  13. what is connection object?

  14. It is used to perform DML operations
    It is used make a connection
    It is used to manipulate data in DB

  15. which method is used to fill that data in dataset

  16. Fall()
    Full()
    Fill()

  17. How will you access data from dataset

  18. By using index
    bu using name of table
    All the above

  19. whihc method of command object do you use to perform Insert operation

  20. ExecuteReader()
    ExceCuteScalar()
    ExcecuteNonQuery()

Tuesday 22 November 2016

JAVASCRIPT Test2

JavaScript

  1. How do you create a function in JavaScript?

  2. function:myFunction()
    function myFunction()
    function = myFunction()

  3. How do you write "Hello World" in an alert box?

  4. alert("Hello World");
    msg("Hello World");
    alertBox("Hello World");

  5. How do you call a function named "myFunction"?.

  6. myFunction()
    call function myFunction()
    call myFunction()

  7. How to write an IF statement in JavaScript?

  8. if i = 5
    if (i == 5)
    if i = 5 then

  9. How to write an IF statement for executing some code if "i" is NOT equal to 5?

  10. if (i <> 5)
    if i =! 5 then
    if (i != 5)

  11. How does a WHILE loop start?

  12. while i = 1 to 10
    while (i <= 10; i++)
    while (i <= 10)

  13. What is the correct way to write a JavaScript array?

  14. var colors = "red", "green", "blue"
    var colors = (1:"red", 2:"green", 3:"blue")
    var colors = ["red", "green", "blue"]

  15. Which operator is used to assign a value to a variable?

  16. =
    *
    /

  17. Boolean(10 > 9)

  18. True
    False
    None

  19. Is JavaScript case-sensitive?

  20. Yes
    No
    May be

Monday 21 November 2016

SQL Advance

SQL

  1. What are the different types of replication available in SQL server?

  2. Snapshot Replication
    Transactional Replication
    Merge Replication
    All of the above.

  3. ACID stands for _______.

  4. Atomic, Cryptic, Independent, Durable
    Atomicity, Consistency, Isolation, Durability
    Automatic, Concurrent, Isolation, Durability
    Atomicity, Consistency, Isolation, Decoupled

  5. Which of the followings are valid Transaction levels in SQL Server?

  6. READ COMMITTED
    READ UNCOMMITTED
    REPEATABLE READ
    All of the above

  7. What is the correct order of query operators in a SQL query?

  8. SELECT -> FROM -> OUTER -> WHERE
    FROM -> OUTER -> WHERE -> ON
    SELECT -> FROM -> WHERE -> OUTER
    FROM -> OUTER -> GROUP BY -> WHERE

  9. RAID stands for ________.

  10. Reduce Array of Independent Disks
    Redundant Array of Independent Disks
    Redundant Automatic Individual Durable
    Redundancy Accelerator Independent Disks

  11. OLTP stands for _________.

  12. Online Transaction Processing
    Offline Transaction Processing
    Ontime Transaction Program
    Online Timebound Processing

  13. Which of the followings are the types of locks in SQL Server?

  14. Shared locks
    Exclusive locks
    Schema locks
    All of the above

  15. What are the different types of temporary tables in SQL server?

  16. Indexed and non-index temporary tables
    Global and local temporary tables
    Unique and shared temporary tables
    Small and large temporary tables

  17. What are the different types of trigger

  18. DDL and DCL
    DDL and DUL
    DML and DTL
    DML and DDL

  19. Which of the following is not a valid data type in SQL server

  20. xml
    nvarchar
    money
    blob

SQL Basic

SQL

  1. What is Primary Key?

  2. Primary keys are unique names of a table.
    Primary keys are integer ids in a table rows.
    Primary keys are unique identifiers for each row in a table.
    None of the above.

  3. which is not a constraint in below options?

  4. Foreign Key
    Unique
    Varchar
    All of the above

  5. A column that automatically generates numeric values is called __________.

  6. Unique column
    Integer column
    Identity column
    Candidate column

  7. Select which is not in Joins?

  8. Inner Join
    Outer Join
    Primary Join
    Cross Join

  9. What are indexes?

  10. Index speed up the data retrieval
    Index stores large number of integer values
    Index minimize the data redundancy
    None of the above.

  11. What is the difference between Primary key and Unique key?

  12. Primary key doesn’t allow null value whereas unique key allows multiple null values
    Primary key allows one null value whereas unique key doesn’t allow null value.
    Primary key doesn’t allow null value whereas unique key allows one null value.
    Primary key allows one null value whereas unique key allows multiple null values.

  13. What is a trigger?

  14. A trigger is a SQL procedure that initiates an action when event (INSERT, DELETE or UPDATE) occurs
    A trigger is an event that can be raised from Stored Procedures.
    A trigger is a SQL procedure that performs some tasks on accessing db tables.
    A trigger is a procedure which executes when an error occurred.

  15. How many types of indexes in SQL server?

  16. Integer and string
    Unique and non-unique
    Clustered and Nonclustered
    None of the above

  17. What is View?

  18. Virtual table
    Physical table
    It's not a virtual table
    None of the above

  19. what is Order by ?

  20. It will arrange in asecnding/ descending order
    It won't arrange in asecnding/ descending order
    It will join the tables
    None of the above

Sunday 20 November 2016

C# Test

C# Test

  1. C# class can inherit multiple ________

  2. Class
    Interface
    Abstract class
    Static class

  3. Which of the followings are value types in C#?

  4. int
    double
    decimal
    All of the abovve

  5. 10 > 9 ? “10 is greater than 9” : “9 is greater than 10” is an example of _______

  6. Ternary operator
    Conditional operator
    Greater than operator
    Inverse operator

  7. What is indexer?

  8. It allows an instance of a class to be indexed like an array
    It allows enumerator with class
    It creates index for instances of a class.
    None of the above.

  9. String data type is ______.

  10. Mutable
    Immutable
    Static
    Value type

  11. An array in C# starts with _____ index.

  12. 0
    1
    -1
    None of the above

  13. Which of the following is right way of declaring an array?

  14. Int[] intArray = new int[];
    Int intArray[] = new int[5];
    Int[] intArray = new int[5];
    Int[] intArray = new int[]{1, 2, 3, 4, 5};

  15. Which of the following statement is true?

  16. try block must be followed by catch and finally block both.
    try block must be followed by catch or finally block or both.
    try block cannot include another try block.
    All of the above.

  17. Data type of a variable declared using var will be assigned at

  18. Runtime
    Compile time
    CLR time
    Application Initialization time.

  19. A partial class allows ________

  20. mplementation of single class in multiple .cs files.
    Declaration of multiple classes in a single .cs file.
    Implementation of multiple interfaces to single class.
    . Multiple class inheritance.

JavaScript Test

JavaScript

  1. JavaScript is ECMAScript

  2. False
    True
    May be
    All of the above

  3. What is null in JavaScript?

  4. Null means empty string value.
    Null means absence of a value.
    Null means unknown value.
    Null means zero value.

  5. Variable in JavaScript declared with which of the following keyword?

  6. int
    Var
    string
    All of the above

  7. Which of the followings are primitive data types in JavaScript?

  8. string
    Number
    Boolean
    All of the above

  9. Which of the following is NOT a JavaScript object?

  10. var obj = {};
    var obj = { name: "Steve"};
    var obj = { name = "Steve"};
    var obj = new Object();

  11. Which of the following is NOT a correct way of declaring an array in JavaScript?

  12. var arr = [1, "two", 3 , 4 ];
    var arr = new Array();
    var[] arr = new Number(){5];
    None of the above

  13. What will 1 == "1" return?

  14. True
    False
    0
    1

  15. How to handle error in JavaScript?

  16. By writing error proof code.
    By using eval().
    By using if-else block
    By using try, catch & finally block.

  17. What will be the output of the following JavaScript code? for(var x = 1; x < 5; x++) c

  18. 11111
    12345
    1234
    None

  19. Which of the following is a valid JavaScript function?

  20. var myFunc = function myFunc(){ };
    function myFunc(){ };
    function(){ };
    function myFunc = { };

SQL Views

SQL Views

- Views are virtual tables that are compiled at run time. The data associated with views are not physically stored in the view, but it is stored in the base tables of the view. A view can be made over one or more database tables. 

- Generally we put those columns in view that we need to retrieve/query again and again. Once you have created the view, you can query view like as table. 

- We can make index, trigger on view.


- In Sql Server we make views for security purpose since it restricts the user to view some columns/fields of the table(s).

- Views show only those columns that are present in the query which is used to make view.One more advantage of Views is, data abstraction since the end user is not aware of all the data present in database table.

Syntax for View



Types of Views

In Sql Server we have two types of views.

01. System Defined Views


02. User Defined Views  

Let's take a look at User Defined views.

User Defined Views  

These types of view are defined by users. We have two types of user defined views.

- Simple Views (When we create a view on a single table, it is called simple view.)
-Complex Views(When we create a view on more than one table, it is called complex view.)

Example of Simple View







In simple view we can insert, update, delete data. We can only insert data in simple view if we have primary key and all not null fields in the view.






Summary

In this article I try to explain the view in sql server with example. I hope after reading this article you understood what SQL VIEW is. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.

Share with your friends! Thanks.......!


   

SQL Union Vs UnionAll


UNION

- The UNION command is used to select related information from two tables, much like the JOIN command. 
- However, when using the UNION command all selected columns need to be of the same data type. 
- With UNION, only distinct values are selected.


UNION ALL

- The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.
- The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.

- A UNION statement effectively does a SELECT DISTINCT on the results set. If you know that all the records returned are unique from your union, use UNION ALL instead, it gives faster results.



1. Employee table data


2. Customer table data




UNION Example (It removes all duplicate records)




UNION ALL Example (It just concatenate records, not eliminate duplicates, so it is faster than UNION)





Summary

In this article I try to explain the differences of UNION and UNION ALL in SQL Server with a simple example. I hope after reading this article you will be able to understand cursors in Sql Server. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.






Saturday 19 November 2016

Delete, Truncate and Drop



Delete(It deletes all data, but not table with structure)

We can delete 1 or more or All rows from a table.

It supports " Where " clause

Slow performance

We can get back rows

It can invoke triggers

Truncate 

We can delete all rows from a table. It is not possible to delete 1 or 2 rows.

It won't support " Where " clause.

High performance

We can't get back rows.

It can't invoke triggers.

Drop (It deletes complete table with structure)

Note#
Truncante is performs better than delete because when you delete the records from the database, database has to perform 2 actions.

                1.delete from the database
                2.write the deleted records into "rollback" segments.

But incase of "Truncate" the second activity is not required.



Summary

In this article I try to explain the diffrence between DELTE , TRUNCATE  and DROP in SQL Server. I hope after reading this article you will be able to understand cursors in Sql Server. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.



SQL Cursors

Cursor


-   Cursors allow roe by row processing of the results. 

-  Cursor is a database object to retrieve data from a result set one row at a time, instead of the T-SQL commands that operate on all the rows in the result set at one time.


- We use cursor when we need to update records in a database table in singleton fashion means row by row.

Life Cycle of Cursor

  1. Declare Cursor

    A cursor is declared by defining the SQL statement that returns a result set.
  2. Open

    A Cursor is opened and populated by executing the SQL statement defined by the cursor.
  3. Fetch

    When cursor is opened, rows can be fetched from the cursor one by one or in a block to do data manipulation.
  4. Close

    After data manipulation, we should close the cursor explicitly.
  5. Deallocate

    Finally, we need to delete the cursor definition and released all the system resources associated with the cursor.

Syntax to Declare Cursor

Declare Cursor SQL Command is used to define the cursor with many options that impact the scalability and loading behavior of the cursor. The basic syntax is given below


Syntax to Open Cursor

A Cursor can be opened locally or globally. By default it is opened locally. The basic syntax to open cursor is given below:



Syntax to Fetch Cursor

Fetch statement provides the many options to retrieve the rows from the cursor. NEXT is the default option. The basic syntax to fetch cursor is given below:


Syntax to Close Cursor

Close statement closed the cursor explicitly. The basic syntax to close cursor is given below:

Syntax to Deallocate Cursor

Deallocate statement delete the cursor definition and free all the system resources associated with the cursor. The basic syntax to close cursor is given below:

SQL SERVER – Simple Examples of Cursors


















Summary
In this article I try to explain the basic of Cursor in SQL Server with a simple example. I hope after reading this article you will be able to understand cursors in Sql Server. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.






SQL Indexes

Indexes

Indexing  is way to sort and search records in the table. It will improve the speed of locating and retrieval of records from the table.It can be compared with the index which we use in the book to search a particular record.

In Sql Server there are two types of Index
1) Clustered Index
2) Non Clustered Index
Clustered Index

- Clustered index physically stored the data of the table in the order of the keys values and the data is resorted every time whenever a new value is inserted or a value is updated in the column on which it is defined.
- In a table only 1 clustered index is possible.
- In a clustered Index, the leaf node contains the actual data.

Non Clustered Index

- In case of Non clustered index it create a separate list of key values (or created a table of pointers) which points towards the location of the data in the data pages.
- In a table 249 non clustered index is possible.
- In a non clustered Index, the leaf node contains the pointer to the data rows of the table.

Guidelines for Clustered Index

With few exceptions, always create clustered indexes on columns frequently used in queires.

Use Clustered Index on columns used in following queries:

1. Queries that return a range of values by using operators such as BETWEEN, >, >=, <, and <=.
2. Queries that return large result sets.
3. Queries that use JOIN clauses using Foreign Key columns.
4. Queries that use ORDER BY or GROUP BY clauses.
For example, an index on the columns specified in the ORDER BY or GROUP BY clause may remove the need for the Database Engine to sort the data, because the rows are already sorted. This improves query performance.


Use Clustered Index on following columns in a table:

1. Columns that are unique or contain many distinct values.
For example, an Author ID uniquely identifies authors. A clustered index or PRIMARY KEY constraint on the AuthorID column would improve the performance of queries that search for author information based on the Author ID.
A clustered index could also be created on author’s FirstName, MiddleName, LastName because author records are frequently grouped and queried in this way, and the combination of these columns would still provide a high degree of difference.
2. Columns that are frequently used to return a range of values by using operators such as BETWEEN, >, >=, <, and <=.
For example, a customer ID uniquely identifies customers in the Customer table. Queries which consist of sequential search, such as WHERE CustomerID BETWEEN 900 and 999, would benefit from a clustered index on CustomerID. This is because the rows would be stored in sorted order on that key column.
3. Columns that are defined as IDENTITY because these columns are guaranteed to be unique within the table.
4. Columns that are frequently used to sort the data retrieved from a table (using ORDER BY clause).
It can be a good idea to cluster (i.e. physically sort) the table on that column to save the cost of a sort operation every time the column is queried.

Clustered Indexes are NOT good for the following columns in a table:

1. Columns that undergo frequent changes.
This causes the whole row to move which affects the performance, because the Database Engine must keep the data values of a row in physical order. This is an important consideration in large-volume transaction processing systems in which data is typically large and volatile.
2. Columns used in Composite keys.

Guidelines for Non-Clustered Index

Consider creating one or more non-clustered indexes on databases or tables with low update requirements, but large volumes of data to improve query performance.
Please note that, large numbers of indexes on a table affect the performance of INSERT, UPDATE, DELETE, and MERGE statements because all indexes must be adjusted appropriately as data in the table changes. Therefore, avoid creating indexes on this kind of tables.


Use Non-Clustered Index on columns used in following queries:

1. Queries that use JOIN or GROUP BY clauses.
Create one or more non-clustered indexes on columns involved in join and grouping operations, and a clustered index on any foreign key columns.
2. Queries that do not return large result sets.
3. Queries that contain frequently involved columns in search conditions, such as WHERE clause, which returns exact match.


Use Non-Clustered Index on following columns in a table:

1. Create non-clustered index on non-key columns that are frequently used in queries.
2. Columns with lots of distinct values, such as a combination of last name and first name, if a clustered index is used for other columns.

A table can have multiple non-clustered indexes?

A table can have multiple non-clustered indexes because they don’t affect the order in which the rows are stored on disk like clustered indexes.

Why can a table have only one clustered index?

Because a clustered index determines the order in which the rows will be stored on disk, having more than one clustered index on one table is impossible. Imagine if we have two clustered indexes on a single table – which index would determine the order in which the rows will be stored? Since the rows of a table can only be sorted to follow just one index, having more than one clustered index is not allowed.



Summary

In this article I try to explain the basic of Cursor in SQL Server with a simple example. I hope after reading this article you will be able to understand cursors in Sql Server. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.



Tuesday 15 November 2016

JavaScript Class


Class in JavaScript

JavaScript ECMAScript 5, does not have class type. So it does not support full object oriented programming concept as other languages like Java or C#. However, you can create a function in such a way so that it will act as a class.
The following example demonstrates how a function can be used like a class in JavaScript.

 As you know, we can create an object of any function using new keyword, so person1 object is created with new keyword. So now, Person will act as a class and person1 & person2 will be its objects (instances). Each object will hold their values separately because all the variables are defined with this keyword which binds them to particular object when we create an object using new keyword.
So this is how a function can be used like a class in the JavaScript.

Add Methods in a Class:

We can add a function expression as a member variable in a function in JavaScript. This function expression will act like a method of class.

In the above example, the Person function includes function expression that is assigned to a member variable getFullName. So now, getFullName() will act like a method of the Person class. It can be called using dot notation e.g. person1.getFullName().

Constructor:

In the other programming languages like Java or C#, a class can have one or more constructors. In JavaScript, a function can have one or more parameters. So, a function with one or more parameters can be used like a constructor where you can pass parameter values at the time or creating an object with new keyword.

In the above example, the Person function includes three parameters FirstName, LastName and Age. These parameters are used to set the values of a respective property.

Note :  Please notice that parameter assigned to a property, if parameter value is not passed while creating an object using new then they will be undefined.