Wednesday, 9 December 2009

Static Classes and Static Class Members (C# Programming Guide)

Static classes and class members are used to create data and functions that can be accessed without creating an instance of the class. Static class members can be used to separate data and behavior that is independent of any object identity: the data and functions do not change regardless of what happens to the object. Static classes can be used when there is no data or behavior in the class that depends on object identity.
Static Classes

A class can be declared static, indicating that it contains only static members. It is not possible to create instances of a static class using the new keyword. Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.

Use a static class to contain methods that are not associated with a particular object. For example, it is a common requirement to create a set of methods that do not act on instance data and are not associated to a specific object in your code. You could use a static class to hold those methods.

The main features of a static class are:

*

They only contain static members.
*

They cannot be instantiated.
*

They are sealed.
*

They cannot contain Instance Constructors (C# Programming Guide).

Creating a static class is therefore much the same as creating a class that contains only static members and a private constructor. A private constructor prevents the class from being instantiated.

The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added. The compiler will guarantee that instances of this class cannot be created.

Static classes are sealed and therefore cannot be inherited. Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values or set up some static state. For more information, see Static Constructors (C# Programming Guide).

Tuesday, 24 November 2009

New sql question

How many levels of Nesting a stored Procedure we can Have? 32
How can we fetch the last Identity Column Inserted in the Table @@IDENTITY,SCOPE_IDENTITY(), IDENT_CURRENT(‘DataTable’)

What is maximum number of subqueries we can write in query in SQL Server 32
What is maximum number of parameters we can add in a stored procedure 2100
Which of the following function will generate a new guid/uniqueidentifier in SQL Server
NEWID()
Which of the following function will return last value inserted into the IDENTITY column of a table @@IDENTITY
How many NonClustered Indexes be able to Created on a Table?
Which index will be created on a table by default using unique key? Non-Clustered Index

What's the maximum value can an INT data type hold? 2,147,483,647
How will you throw exception from stored procedure? @@raiseerror

You can view the nest level in a stored procedure by using the following command: SELECT @@NESTLEVEL

In SQL Server 2000, the page size is ? 8kb

We can Get List of Triggers :
select * from Sys.Objects where Type='tr'
SELECT *FROM sys.procedures;
SELECT * FROM sys.Tables

Cursor attribute is belonged to the language? pl/sql

Monday, 9 November 2009

CAPTCHA ?

!.Full Form Of CAPTCHA ?
Ans:-Completely Automated Public Turing test to tell Computers and Humans Apart"

Saturday, 7 November 2009

Please get the 4 th maximum salary from a table without using any sql keyword (TOP,MAX are mot allowed)

Create Table 'Employee' with columns 'Emp_Name'
and 'Salary'. And, Insert some data.....

Cursor:
declare Cursor_Name cursor scroll
for select salary from Emploee order by salary desc
open Cursor_Name
fetch absolute 4 from Cursor_Name
deallocate Cursor_Name

What is difference between TRUNCATE & DELETE?

TRUNCATE SQL Command:

TRUNCATE is faster and uses fewer system and transaction log resources than DELETE.

TRUNCATE removes the data by deallocating the data pages used to store the table’s data, and only the page deallocations are recorded in the transaction log.

TRUNCATE removes all rows from a table, but the table structure and its columns, constraints, indexes and so on remain. The counter used by an identity for new rows is reset to the seed for the column.

You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint.

Because TRUNCATE TABLE is not logged, it cannot activate a trigger.

TRUNCATE can not be Rolled back.

TRUNCATE is DDL Command.

TRUNCATE Resets identity of the table.

DELETE SQL Command:

DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.

If you want to retain the identity counter, use DELETE instead. If you want to remove table definition and its data, use the DROP TABLE statement.

DELETE Can be used with or without a WHERE clause
DELETE Activates Triggers.
DELETE can be Rolled back.
DELETE is DML Command.
DELETE does not reset identity of the table.

-----------------------------------------------------------
This is the most appropriate answer.
-----------------------------------------------------------


Is This Answer Correct ? 0 Yes 0 No