Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
learning_grsql
Posting Yak Master
230 Posts |
Posted - 2012-06-25 : 13:58:22
|
| I just started learning sql.I see "@" in many examples from different websites including in my previous posts. I wonder why we place "@" in queries. example - example : DECLARE @T TABLE (ColA INT, ColB INT)...........................I read in different sources that we place "@" for something called parameter.I don't want to go deep into it for now but I would like to know why we use that in queries which start with "Declare". And when we create table starting with Declare statement. Will it create physical table?I pasted codes from my previous post, but I don't see any physical table but only output (sql server 2005).my previous post link : http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=176067 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-06-25 : 14:10:57
|
| Hi,Whenever you see '@' think of having a VARIABLE which can be any type; INT, CHAR,VARCHAR, TABLE...etc.declared variable of type table will be only valid inside and temporary in your program. IT IS NOT A PHYSICAL or TEMPORARY TABLE. (temp tables are found under tempdb databases under SQL Server).overall they can only be used temporary during the run time of your script.Luck,kml |
 |
|
|
learning_grsql
Posting Yak Master
230 Posts |
Posted - 2012-06-30 : 05:28:34
|
Thank youquote: IT IS NOT A PHYSICAL or TEMPORARY TABLE. (temp tables are found under tempdb databases under SQL Server).
Do you mean it is not a temporary table? I thought if it's not a physical table, it should be a temporary table. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2012-06-30 : 16:59:44
|
quote: Originally posted by learning_grsql Thank youquote: IT IS NOT A PHYSICAL or TEMPORARY TABLE. (temp tables are found under tempdb databases under SQL Server).
Do you mean it is not a temporary table? I thought if it's not a physical table, it should be a temporary table.
It's just not termed a temporary table as those start with # instead of @. But it is indeed temporary in that it goes away when the session does.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
|
|
|
|
|