Iwas Bornready (9/1/2016)
Derek Slinn (9/1/2016)
I think the answer is wrong,
Both are stored in tempdb database.
technically table variables can just be in memory if there is only a small amount of data in them and it will page to tempdb if its gets bigger
That's what I thought.
I would say it depends. The data for both starts on RAM and when they grow it's thrown to disk.
However, their definitions are stored on tempdb since the beginning. Table variables are stored as a temp table with an eight character name preceded by #.
DECLARE @Date datetime = DATEADD( ms, -10, GETDATE());
DECLARE @MyTable TABLE(someid int);
WHERE create_date BETWEEN @Date AND DATEADD( ms, 20, GETDATE());
How to post data/code on a forum to get the best help: Option 1 / Option 2
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?