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 |
|
Sikha
Starting Member
2 Posts |
Posted - 2005-12-07 : 10:24:10
|
| Hello: I have a question: If I create a temporary table (in SQL Server 2005) in the following manner:CREATE TABLE #Yaks (YakID int,YakName char(30) )How can I insert data into the temporary table? The regular INSERT does not seem to work. Also, how can I then view the data from this temporary table? SELECT *from #Yaks did not give me anything. Why? Where is the table located? How can I view all it's data? How can I view the temporary table (the field names and field types) in SQL Server 2005? Your input will be highly appreciated. Thank you very much, Sikha Bagui |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2005-12-07 : 11:54:57
|
| it must be in the 'same context'temp tables die/get delete automatically if you try to reference them outside their 'context'.a context may be a particular sql connection, or a different sql batch, or a different sql procedure.create #xinsert into #xselect #xSHOULD work, howevercreate #xgoinsert into #xgoselect #xgowon'tsearch here (or BOL) for info on "context" and "temp" and "tables" |
 |
|
|
ssrikrish
Yak Posting Veteran
69 Posts |
Posted - 2005-12-17 : 16:19:12
|
| There is no difference between the local temp tables in SQL 2K and SQL 2005. It will work in the same context. You cannot refer the local temp table outside its scope of reference. If you want to access it globally, create a global temp table using ##<<tablename>>. Please note that a global temp table exists until the creating connection terminates and all current use of the table completes. After the creating conn terminates, however, only those connections already accessing it are allowed to finish, and no further use of the table is allowed. |
 |
|
|
|
|
|