Reputation:
I keep getting this error but I don't know why as I've already declared the variable.
DECLARE @SizeAttributeTable TABLE (
Id int NOT NULL identity(0,1),
PpamId int, PvavId int,
AttributeName varchar(20),
AttributeValue varchar(50),
ProductId int
)
INSERT INTO @SizeAttributeTable (PpamId, PvavId, AttributeName, AttributeValue, ProductId )
SELECT
ppam.Id, pvav.ProductVariantAttributeId, pa.Name, pvav.Name, p.Id
FROM
ProductVariantAttributevalue pvav, Product_ProductAttribute_Mapping ppam, Product p, ProductAttribute pa
WHERE
[pvav].ProductVariantAttributeId = [ppam].Id
AND [p].Id = ppam.ProductId
AND [pa].Id = [ppam].ProductAttributeId
AND pa.Name = 'Size'
ORDER BY
p.Id, pvav.Id, pvav.Name
print(@SizeAttributeTable) --error points here
Can anyone advise me? Thanks
Upvotes: 0
Views: 122
Reputation: 6566
Print a table value variable is prohibited in sql server. try using SELECT statement
Upvotes: 0
Reputation: 1609
You can't "print" a table, you can SELECT * FROM @SizeAttributeTable
though.
Print
is generally for displaying a single value of datatypes other than tables like:
DECLARE @SomeString VARCHAR(20) = 'Test Print'
PRINT(@SomeString)
Upvotes: 4