Stuck without writing rights in a big database? Only allowed to dbo_reader?
Then this baby is for you:

DECLARE @myTable AS TABLE (rowid int, name varchar)

This neat little row can be used instead of temp-tables to store subsets of data to increase the performance of your joins. It´s more simple and requires fewer data to just subselect the first amount of data before joining with another table. Instead of joining each row in both tables using this you can focus on the rows from one table that you really want and skip the rest.

There are some limitations of course but I´ve used it like this and it worked fine:

DECLARE @myTable TABLE (rowid INT, thedate datetime)

INSERT INTO @myTable (rowid, thedate)
SELECT someid, somedate FROM anothertable WHERE somevalue = 22

SELECT * FROM @myTable

Yummy!

Why not join the newsletter?

Why not join the newsletter?

If you're not a fan of facebook or twitter, sign up to the newsletter and I'll send you a quick update every so often with what's going on and new posts coming out.

You have Successfully Subscribed!