Connecting Tech Pros Worldwide Help | Site Map

How do you create a new table with different field names

Jim's wife
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi all

I need to create a new table based on a source table.
The new table is almost the same as the source table in that just some field
names must change, and a few new fields added or dropped?

I was thinking of renaming the fields somehow, then using sql to add /drop?

Please give an example.

What is the best way to approach?
Thanks



David B
Guest
 
Posts: n/a
#2: Nov 12 '05

re: How do you create a new table with different field names


Keep it simple ! Use a make table query. You can change the field name by
putting a new name in front of the existing one at the top of the query grid
with a colon between. Like this - Newname:existingname
HTH
David B
Hexham UK

Jim's wife <tabitha@mindspring.com> wrote in message
news:PVOQb.18586$O22.12505078@news4.srv.hcvlny.cv. net...[color=blue]
> Hi all
>
> I need to create a new table based on a source table.
> The new table is almost the same as the source table in that just some field
> names must change, and a few new fields added or dropped?
>
> I was thinking of renaming the fields somehow, then using sql to add /drop?
>
> Please give an example.
>
> What is the best way to approach?
> Thanks
>
>
>[/color]

Larry Linson
Guest
 
Posts: n/a
#3: Nov 12 '05

re: How do you create a new table with different field names


The simplest way is, in the database window, highlight the table, copy and
paste it -- you'll be asked for a new name. Then open the new table in
design view and make the changes.

Larry Linson
Microsoft Access MVP

"Jim's wife" <tabitha@mindspring.com> wrote in message
news:PVOQb.18586$O22.12505078@news4.srv.hcvlny.cv. net...[color=blue]
> Hi all
>
> I need to create a new table based on a source table.
> The new table is almost the same as the source table in that just some[/color]
field[color=blue]
> names must change, and a few new fields added or dropped?
>
> I was thinking of renaming the fields somehow, then using sql to add[/color]
/drop?[color=blue]
>
> Please give an example.
>
> What is the best way to approach?
> Thanks
>
>
>[/color]


Jim's wife
Guest
 
Posts: n/a
#4: Nov 12 '05

re: How do you create a new table with different field names


Hi all

Thanks for your help.
But I need to do this in code. Thanks!!

I look forward to your replies






"Jim's wife" <tabitha@mindspring.com> wrote in message
news:PVOQb.18586$O22.12505078@news4.srv.hcvlny.cv. net...[color=blue]
> Hi all
>
> I need to create a new table based on a source table.
> The new table is almost the same as the source table in that just some[/color]
field[color=blue]
> names must change, and a few new fields added or dropped?
>
> I was thinking of renaming the fields somehow, then using sql to add[/color]
/drop?[color=blue]
>
> Please give an example.
>
> What is the best way to approach?
> Thanks
>
>
>[/color]


Jim's wife
Guest
 
Posts: n/a
#5: Nov 12 '05

re: How do you create a new table with different field names


This works great until I have a field with spaces.
I get an error when there are spaces. I can't even do [New Fieldname]

is there a special character for a space I can try?

Thanks



"David B" <david@marleycotenospam.fsnet.co.uk> wrote in message
news:bv0ijt$t73$1@newsg3.svr.pol.co.uk...[color=blue]
> Keep it simple ! Use a make table query. You can change the field name[/color]
by[color=blue]
> putting a new name in front of the existing one at the top of the query[/color]
grid[color=blue]
> with a colon between. Like this - Newname:existingname
> HTH
> David B
> Hexham UK
>
> Jim's wife <tabitha@mindspring.com> wrote in message
> news:PVOQb.18586$O22.12505078@news4.srv.hcvlny.cv. net...[color=green]
> > Hi all
> >
> > I need to create a new table based on a source table.
> > The new table is almost the same as the source table in that just some[/color][/color]
field[color=blue][color=green]
> > names must change, and a few new fields added or dropped?
> >
> > I was thinking of renaming the fields somehow, then using sql to add[/color][/color]
/drop?[color=blue][color=green]
> >
> > Please give an example.
> >
> > What is the best way to approach?
> > Thanks
> >
> >
> >[/color]
>[/color]


Leon
Guest
 
Posts: n/a
#6: Nov 12 '05

re: How do you create a new table with different field names



Użytkownik "Jim's wife" <tabitha@mindspring.com> napisał w wiadomości
news:PVOQb.18586
[color=blue]
> I need to create a new table based on a source table.
> The new table is almost the same as the source table in that just some[/color]
field[color=blue]
> names must change, and a few new fields added or dropped?
> I was thinking of renaming the fields somehow, then using sql to add[/color]
/drop?

Hi!

Executing this:
SELECT * INTO YourNewTable FROM YourSourceTable
all data from the YourSourceTable will be copied to YourNewTable.
When you set condition WHERE to eg. 1=2, then you obtain new, empty table
named YourNewTable.

SELECT YourSourceTable.OldFieldName AS NewFieldName YourNewTable FROM
YourSourceTable;
Using this syntax you can set a new name to a specified field.

You may also change numbers of fields by creating new ones or droping
existing.
ALTER TABLE YourNewTable ADD COLUMN NewColumn DATE;
ALTER TABLE YourNewTable DROP COLUMN ColumnYouDontWant;

Leon!


Jim's wife
Guest
 
Posts: n/a
#7: Nov 12 '05

re: How do you create a new table with different field names


thanks all

the sql strings in code worked using [renamed field]
for some reason it doesnt in the query designer



"Jim's wife" <tabitha@mindspring.com> wrote in message
news:PVOQb.18586$O22.12505078@news4.srv.hcvlny.cv. net...[color=blue]
> Hi all
>
> I need to create a new table based on a source table.
> The new table is almost the same as the source table in that just some[/color]
field[color=blue]
> names must change, and a few new fields added or dropped?
>
> I was thinking of renaming the fields somehow, then using sql to add[/color]
/drop?[color=blue]
>
> Please give an example.
>
> What is the best way to approach?
> Thanks
>
>
>[/color]


Closed Thread