Is a special data type that can be used to store a result set for processing at a later time.
table is primarily used for temporary storage of a set of rows returned as the result set of a table-valued function.
Test Table AS TABLE ( ID INT, Name NVARCHAR(40) ) --Declaring table variable DECLARE @Test Table AS dbo.
Table variables store a set of records, so naturally the declaration syntax looks very similar to a CREATE TABLE statement, as you can see in the following example: You might think table variables work just like temporary tables (CREATE TABLE #Product Totals), but there are some differences.
Unlike the majority of the other data types in SQL Server, you cannot use a table variable as an input or an output parameter.
Common table expressions can also be used with the SELECT, INSERT, DELETE, and CREATE VIEW statements.
For more information, see WITH common_table_expression (Transact-SQL). For information about table hints, see Table Hints (Transact-SQL).
The only constraint types allowed are PRIMARY KEY, UNIQUE KEY, and NULL.
For more information about the syntax, see CREATE TABLE (Transact-SQL), CREATE FUNCTION (Transact-SQL), and DECLARE @local_variable (Transact-SQL).
Transact-SQL Syntax Conventions Is the same subset of information that is used to define a table in CREATE TABLE.
The table declaration includes column definitions, names, data types, and constraints.
Specifies the temporary named result set or view, also known as common table expression (CTE), defined within the scope of the UPDATE statement.
The CTE result set is derived from a simple query and is referenced by UPDATE statement.
TOP ( ) Specifies one or more table hints that are allowed for a target table. @ When referencing the Unicode character data types nchar, nvarchar, and ntext, 'expression' should be prefixed with the capital letter ' N'.