Monday, June 8, 2009

How to use Table Variable and advantage of Table variable

Syntax of Table Variable-
DECLARE @TestTable TABLE
(
Pid int,
Pdesc varchar(200)
)
You can use table variables in batches, stored procedures, and user-defined functions (UDFs). We can UPDATE records in our table variable as well as DELETE records.
Update @TestTable Set Pdesc ='PEN' where Pid =1
Select * from @TestTable
Advantage-It provide less locking and logging overhead than table Variable.

No comments:

Post a Comment