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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating an existing table structure 1

Status
Not open for further replies.

rilkyn

Technical User
Jan 19, 2005
33
GB
I have imported data from an excel spreadsheet which has created a table where I am missing column names or the column names are not correct.

I know how to change the column names and can manually insert columns by creating a 'select into' query. What I can't do is insert the new columns with a default value( when the query is currently run a text box appears requesting what the value should be). Is there a command that allows you to do this? I am trying to automate this as much as possible so that each query runs through a macro activated button.

Eg
macro 1 imports the data from several excel spreadsheets into 4 tables with the same table strucuture.
Macro 2 updates the newly created tables by either creating new tables in the correct table structure or updating the imported tables into the correct structure.

Eventually all the tables are combined into 1 which is then used for running queries against.
 
When you say default value, do you mean set the default property, or insert some default data? If it is the second, you can assign a valuse when adding a column. For example:

SELECT OldTable.AudID, OldTable.AudType, 115 AS NewColNmbr, "New" AS NewColText INTO NewTable
FROM OldTable;

If it is the first, now might be a good time to look at code, rather than macros.:)


 
Luckily it was the latter. Sorry for not being clear and thank you for the right answer. I'ver been struggling with this on and off for a couple of days. I almost resorted to getting the manuals out.

Thanks again. Now I can go and look clever for my boss. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top