Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2007-11-01 : 07:28:03
|
| Hi experts,what is the scope of # and what is the scope of @create table #temp(COLUMN01 VARCHAR(500))DECLARE @TEMP TABLE(COLUMN01 VARCHAR(500))thanks in advanceVinodEven you learn 1%, Learn it with 100% confidence. |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2007-11-01 : 07:36:14
|
from BOL... quote: Table variables provide the following benefits: A table variable behaves like a local variable. It has a well-defined scope. This is the function, stored procedure, or batch that it is declared in. Within its scope, a table variable can be used like a regular table. It may be applied anywhere a table or table expression is used in SELECT, INSERT, UPDATE, and DELETE statements.......table variables are automatically cleaned up at the end of the function, stored procedure, or batch in which they are defined. CHECK constraints, DEFAULT values and computed columns in the table type declaration cannot call user-defined functions.table variables used in stored procedures cause fewer recompilations of the stored procedures than when temporary tables are used.Transactions involving table variables last only for the duration of an update on the table variable. Therefore, table variables require less locking and logging resources.Indexes cannot be created explicitly on table variables, and no statistics are kept on table variables. In some cases, performance may improve by using temporary tables instead, which support indexes and statistics. For more information about temporary tables, see CREATE TABLE (Transact-SQL).
Em |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|