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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-06-21 : 08:19:44
|
| MM submitted "Is it possible to insert into a temparary table and not have to define the schema of the table, but reference one of the schema for a table you already have?Example Instead of CREATE TABLE #t(x INT PRIMARY KEY)INSERT INTO #t VALUES (2)SELECT Test2Col = x FROM #tCan you bind the temp table to an existing table?or do something like...CREATE TABLE #t(Schema.TableNameX)INSERT INTO #t VALUES (2)SELECT Test2Col = x FROM #t" |
|
|
jasper_smith
SQL Server MVP & SQLTeam MVY
846 Posts |
Posted - 2002-06-21 : 08:52:59
|
| Check BOL for select...into...Its not just limited to temporary tables.However I would suggest you always explicitly create the temp tableHere's an example with data..use pubsgoselect * into #authorstemp from authorsgoselect * from #authorstempgodrop table #authorstempgoHere's an example without data (schema only)..use pubsgoselect * into #authorstemp from authors where 1=0gouse tempdbgosp_help #authorstempgodrop table #authorstempgoHTHJasper Smith |
 |
|
|
|
|
|