Published: 23 Apr 2021 › Updated: 23 Apr 2021
Table variable in SQL Server
Let's have a preview of this amazing thing that is the Table variable in SQL Server.
Basic syntax
DECLARE @DevExperts TABLE
(Id INT PRIMARY KEY IDENTITY(1,1),
Name VARCHAR(MAX),
Country VARCHAR(MAX))
The column Id is defined to be the primary key and to iterate automatically.
Basic insert
INSERT INTO @DevExperts VALUES
('Ada Lovelace', 'Uk'),
('Evelyn Boyd Granville', 'US'),
('Carol Shaw', 'US'),
('Adi Polak', 'global'),
('Trisha Gee', 'Spain'),
('Mala Gupta', 'India')
SELECT * FROM @DevExperts
The output is
Leave Table variable in SQL Server to:
Read more #hive-169321 posts
Best Posts From Laura Durieux
We have not curated any of lauweded's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.