VistaDB 6
VistaDB / Developer's Guide / SQL Reference / Temp Tables / Table Variable Example
In This Topic
Table Variable Example
In This Topic
Tables as a variable live only for the life of the single execution syntax and are automatically cleaned up. There is no need to drop this type of table.
Table Variable Example
Copy Code
PRINT 'Test Table Variable';

DECLARE @CustomersTemp TABLE (
ID int,
CustomerName varchar(30),
City varchar(50),
State varchar(50)
);

INSERT INTO @CustomersTemp (ID, CustomerName, City, State)
SELECT    *
FROM    customers
WHERE    state = 'florida';

declare @tvprows int;

set @tvprows = select count(id) from @CustomersTemp;

print 'Table variable contains:';
print @tvprows;

-- No need to drop the temp table here because it is a table variable
-- It will be cleaned up in scope
-- drop table @customertemp;
See Also