562 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Speed comparison of temporary tables against table variables
Part four of a five-part series of blogs
When you are programming in SQL, you often have the choice of using table variables or temporary tables. This blog considers whether one method is substantially quicker than the other (spoiler alert: not really).
The SQL query to generate the table of rows for table variables is nearly identical to the one for using a temporary table:
-- create a new one
DECLARE @AdviceRows TABLE (
-- the number of rows to generate
DECLARE @max int = 100000
-- loop counter used and string variable
DECLARE @i int = 1
DECLARE @s varchar(100)
-- keep going till we've created enough rows
WHILE @i <=>=>
-- text to store
SET @s =
WHEN @i % 3 = 0 THEN 'This too shall pass'
WHEN @i % 3 = 1 THEN 'Look before you leap'
ELSE 'Fortune favours the brave'
INSERT INTO @AdviceRows (ID,OwlyAdvice)
SET @i = @i + 1
a.OwlyAdvice AS Advice,
COUNT(*) AS Frequency
@AdviceRows AS a
SELECT * FROM @AdviceRows
Now we've seen the two test queries, it's time to compare the results!
|Parts of this blog|
25 Aytoun Street