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