Should it be dependent on the version of SQL Server targeted on?
In fact, the article referenced for this question was only focused on SQL 2000.
In your reference article, it clearly presented the sample code,
Listing 2. Using a table variable.
declare @t table
(OrderID int primary key,
RequiredDate datetime not null,
ShippedDate datetime null)
insert @t
select o1.OrderID, o1.RequiredDate, o1.ShippedDate
from Orders o1
where
o1.EmployeeID = 9
select o1.OrderID, (select count (*) from @t o2
where
(o2.RequiredDate < o1.RequiredDate
or (o2.RequiredDate = o1.RequiredDate
and o2.OrderID <= o1.OrderID)))
as SequenceNo, o1.RequiredDate, o1.ShippedDate
from @t o1
order by o1.RequiredDate
in which a primary key was explicitly created.
This is contradicted to the later version SQL Server on Limitations and Restrictions for table variable. Reference: http://msdn.microsoft.com/en-us/library/ms175010%28v=sql.105%29.aspx