Change field name programically

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

I have a table, MyTable
It has a field called Memory (MB)
This plays havoc with trying to do things because it has a space and
( ) brakets. How do I programically rename the field to say MemoryMB
This is data that automatically gets imported so i have to get it this
way.

Thanks.
 
I have a table, MyTable
It has a field called Memory (MB)
This plays havoc with trying to do things because it has a space and
( ) brakets. How do I programically rename the field to say MemoryMB
This is data that automatically gets imported so i have to get it this
way.

Thanks.

I guess I should say that the field is the name of a column in a table
 
1) Just put [] around the field name when you use it.
2) Import the data into a temporary table use an insert query to
insert it into a table that has the field name you want.
 
I have a table, MyTable
It has a field called Memory (MB)
This plays havoc with trying to do things because it has a space and
( ) brakets. How do I programically rename the field to say MemoryMB
This is data that automatically gets imported so i have to get it this
way.

Thanks.

How are you doing the automatic import? You can certainly have your own local
table with whatever fieldnames you like - MemoryMB for example - and Append
data from an external source into this local table. It is not necessary for
the fieldnames to be identical; you can append from a field named [Memory
(MB)] into a field named [MemoryMB] or a field named [SizeOfMemory] or
whatever you like.

John W. Vinson [MVP]
 
in SQL Server it's easy to go through and fix things like this

you simply query syscolumns and sysobjects; and then you rename the
columns with spaces in them.. I mean-- come on

don't ever use spaces in field names for anything

-Aaron


I have a table, MyTable
It has a field called Memory (MB)
This plays havoc with trying to do things because it has a space and
( ) brakets. How do I programically rename the field to say MemoryMB
This is data that automatically gets imported so i have to get it this
way.

How are you doing the automatic import? You can certainly have your own local
table with whatever fieldnames you like - MemoryMB for example - and Append
data from an external source into this local table. It is not necessary for
the fieldnames to be identical; you can append from a field named [Memory
(MB)] into a field named [MemoryMB] or a field named [SizeOfMemory] or
whatever you like.

John W. Vinson [MVP]
 
Back
Top