TSQL, Table variable

Table variables is like of temporary table in TSQL,
Table variables is useful for storing variables in the tables format.
by using table variables, table functions can be found here, and its profits, tablevariables will automatically clear out after a store procedure or function call is complete.
Example Table variables:
DECLARE @table AS TABLE (
id INT,
Nama VARCHAR(50))

INSERT INTO @table VALUES (1, 'namaku')
INSERT INTO @table VALUES (2, 'namanya')

SELECT * FROM @table

see the image:

result of table variable

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.