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 |
|
tchinedu
Yak Posting Veteran
71 Posts |
Posted - 2005-12-15 : 17:54:58
|
| Please help guys,I want to be able to create a variable table dynamically based on the rows in a reference tableI have a reference table containing rows I need to use for calculations with each row defining column nameseg: refTable--- ColName-----ColText------------FieldType=============================================--LName ----- 'Last Name' -------- varchar---FName ----- 'First Name' ------ varChar---SSNum ----- 'Social Security' -- numeric etc.I want to be able to read the columns in this table and use them to create a variable table in memory at runtimeex. create @tablenew table ( -- append the colName values here dynamically -- so this var table columns is always reflecting the -- columns in the reftable )Is this possible. I'm trying to avoid having to change the procedureeverytime a new field is added to the ref table |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-16 : 00:15:45
|
| Why do you want to create table dynamically?If you want to simulate the table structure, thenSelect * into #tempTable from yourTable where 1=0Insert into #tempTable select * from yourTable -- If you want to copy the rowsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|