Monday, November 29, 2010

Difference between cast() and convert() in sql server 2005.

Both function are used in Sql server for explicit conversion of data from one data type to another data type. But using convert() function , data will convert in formated manner , not in cast() function.
For Example:-
cast()
cast(data as datatype)
select cast(getdate() as varchar(100))
output -- Nov 29 2010  5:39PM


convert()
convert(datatype,data,formate)
select  convert(varchar,getdate(),105)
output -- 29-11-2010

what is optimistic and premistic locking in Database

Optimistic locking assumes that no one would read or change the data while changes are being by a bean
Pessimistic locking would rather lock down the data so that no one can access it


or


In optimistic locking the row will not be locked until the actual update is performed. In order to prevent the lost update issue a version number column will be used. In pessimistic locking the row will be locked at the time when the data is selected from the database. This will prevent other users who want to update the same record. This should not prevent the readers but this behaviour varies from database to database.

Monday, November 22, 2010

What are Magic tables in SQL SERVER

There are two magic tables named inserted and deleted.

On Insertion :
whenever an insert takes place, the data goes into inserted
table before the commit of the transaction.

On Deletion :
Whenever a row gets deleted from a table, data goes into
deleted table.

On Update :
Since an update statement is a combination of delete and
insert so in case of update data goes in both, inserted and
deleted tables.

some usefull code of C#

click on this link for some usefull C# code

http://www.fincher.org/tips/Languages/csharp.shtml

Saturday, October 30, 2010

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.

Wednesday, September 29, 2010

How to Add ---Select--- in your Dropdown at run time when ur Dropdown bind with datasource.

How to Add ---Select--- in your Dropdown at run time when ur Dropdown bind with datasource.

a very simple step u can do it

Just write like this

Dropdown1.datasource=datatable;
Dropdown1.dataBind();
Dropdown1.Items.Insert(0,new ListItem("--Select--","-1"));