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

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.

Wednesday, August 25, 2010

Temporary Table in Sql Server 2005

Temporary tables are created in tempdb . And this table is created with prefixed with a pound sign(#). This tells SQL Server that this table is a local temporary table. This table is only visible to this session of SQL Server. When close the session the table will be  automatically dropped. This can be created as just like other table with a few exceptions.it can't have forgin key constraints on Temporary Table.
Example:-
Create table #tablename(column name datatype,......)
insert into #tablename(column name..)  values(value.....)

it has almost comman behaviour like normal table.

Tuesday, August 24, 2010

Delay Function in SQL SERVER

In sql server 2005 , we can use delay function for waiting , For Example

----Delay for  seconds


WAITFOR DELAY '000:00:10'

SELECT '10 Second Delay'

GO

----Delay till 1 AM

WAITFOR TIME '1:00:00'

SELECT  'Time is 1 AM'

GO