Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

appending a column to a table?

Status
Not open for further replies.

bitsa

Technical User
Dec 31, 2004
1
US
Is it possible to write a query that appends a column to a table, the contents of which come from another table, and then save that table so that the process can be repeated?

For example, I have a table that has a field called status. I run another query ("new") which creates another table with the current status as of that date.

I'd like to merge the two so that I end up with a table that has the status field in it from each subsequent run of "new"

E.g.
company, status
becomes company, status, status.t1, status.t2

Thanks,
bitsa
 
You can't append a column to an existing table, so create a new table formed from joining the two tables and then selects the columns you want
Simon Rouse
 
You can add a column definition to a table with
Code:
ALTER TABLE tbl ADD COLUMN NewCol ...
syntax. You could then, in a separate step issue an UPDATE tbl SET statement to set the values.

You appear to be attempting to make a DBMS act like a spreadsheet. As you are discovering, that's not so easy and the results are usually not very pleasing.

You may be better off to place your "status" fields in a single table with suitable keys (dates for example) to distinguish among them and then look at a crosstab query to get your "spreadsheet" display.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top