How do you create a new table with different field names

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim's wife

    How do you create a new table with different field names

    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

    #2
    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:existin gname
    HTH
    David B
    Hexham UK

    Jim's wife <tabitha@mindsp ring.com> wrote in message
    news:PVOQb.1858 6$O22.12505078@ news4.srv.hcvln y.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]

    Comment

    • Larry  Linson

      #3
      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@mindsp ring.com> wrote in message
      news:PVOQb.1858 6$O22.12505078@ news4.srv.hcvln y.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]


      Comment

      • Jim's wife

        #4
        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@mindsp ring.com> wrote in message
        news:PVOQb.1858 6$O22.12505078@ news4.srv.hcvln y.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]


        Comment

        • Jim's wife

          #5
          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@marleyco tenospam.fsnet. co.uk> wrote in message
          news:bv0ijt$t73 $1@newsg3.svr.p ol.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:existin gname
          > HTH
          > David B
          > Hexham UK
          >
          > Jim's wife <tabitha@mindsp ring.com> wrote in message
          > news:PVOQb.1858 6$O22.12505078@ news4.srv.hcvln y.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]


          Comment

          • Leon

            #6
            Re: How do you create a new table with different field names


            U¿ytkownik "Jim's wife" <tabitha@mindsp ring.com> napisa³ w wiadomo¶ci
            news:PVOQb.1858 6
            [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 ColumnYouDontWa nt;

            Leon!


            Comment

            • Jim's wife

              #7
              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@mindsp ring.com> wrote in message
              news:PVOQb.1858 6$O22.12505078@ news4.srv.hcvln y.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]


              Comment

              Working...