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 |
|
rubs_65
Posting Yak Master
144 Posts |
Posted - 2005-01-28 : 15:00:32
|
| Hi,We have to dynamically create a table in temp database based on other database and we are using:select * into tempdb..table1 from table1 where 0=1This works fine but it also copy the null or not null property and we want all columns to be null in new table. we are currentlt create table like this and then alter all columns to be null so we are looking if there is any better way to create tables with structure without null/not null property?Thanks--rubs |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-01-28 : 15:28:10
|
| The best way would be to not use select * into. Just use CREATE TABLE to create your tables that way you can define how it should look.Tara |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-01-28 : 20:38:43
|
| And, never create tables, other than #temp tables in tempdb. That's just asking for trouble.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
Hyukevain
Yak Posting Veteran
66 Posts |
Posted - 2005-01-29 : 10:56:00
|
| Just like tara said, create new table in your temp DB, to dynamically retrieve column name, type and other properties, just create a script to retrieve it from syscolumns table. |
 |
|
|
|
|
|