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"));

Tuesday, September 7, 2010

Last generated identity value on table in SQL SERVER 2005

SQL SERVER provides three different functions for capturing the last generated identity value on a table that contains an identity column:-


(a) select  @@IDENTITY

(b) select  SCOPE_IDENTITY()

(C) select  IDENT_CURRENT('tableName')


IDENT_CURRENT is similar to the Microsoft® SQL Server™ 2000 identity functions SCOPE_IDENTITY and @@IDENTITY. All three functions return last-generated identity values. However, the scope and session on which 'last' is defined in each of these functions differ.
  • IDENT_CURRENT returns the last identity value generated for a specific table in any session and any scope.
  • @@IDENTITY returns the last identity value generated for any table in the current session, across all scopes.
  • SCOPE_IDENTITY returns the last identity value generated for any table in the current session and the current scope.

How can optimize a Stored Procedure?

when used in stored procedure , the RETURN statement can specify an integer value to procedure. If no value is specified on RETURN , a stored procedure returns 0 , The stored procedure returns a value 0 when no errors were encountered . Any non-zero value indicates as error occured.