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 - 2003-09-23 : 08:02:37
|
| Darren writes "I have a script that creates 3 global (##)temporary tables using the select...into command. I then use DTS to export the contents of the tables into text files and a database on another server.To complicate matters, two of the hash tables are created using dynamic SQL so the columns may vary.Is it possible to generate a create script for the temp tables that I could use to set up the destination tables? Failing that, is there a way to return just the column names for a given temp table? I've tried the INFORMATION_SCHEMA.COLUMNS view but it doesn't work for temp tables.I'm using SQL Server 2000 on Windows 2000" |
|
|
Wingenious
Starting Member
11 Posts |
Posted - 2003-09-23 : 08:57:33
|
| For the column names you could use something like this...SELECT O.name,C.name FROM tempdb.dbo.sysobjects AS O JOIN tempdb.dbo.syscolumns AS C ON C.id = O.id AND O.name LIKE '##%'You could then build on this to generate a CREATE TABLE script. |
 |
|
|
|
|
|