March 10, 2005 at 2:39 am
When & why should I use table variables instead of temporary tables???
March 10, 2005 at 10:15 am
A starter for you.
Variables are designed to hold one value at a time, whereas temporary tables contain rows and rows of data. You could if wanted to, assign a row of data to various variables, but you will only ever have one row of data at a time.
A temporary table allows you to temporarily keep multiple rows of data that you can play around with before losing the contents.
Key use of a variable is holding constant values. When updates are required you only have to change the variable, rather than searching and replacing through the code.
Key use of temporary table is to get some values back, do something with them and then destroy. E.g create a temp table, link it to another table, perform an update...etc, then display the results to user without keeping a permanent table which will use space.
These are very basic examples. Search this site for some real life examples.
March 10, 2005 at 11:03 am
Note, the question was regarding Table variables, not variables designed to hold single scalar values.
Try this recent thread on the same subject:
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=157332&p=2
March 11, 2005 at 5:30 am
Whoops. Misread completely.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy