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

Change column name with containing two words 1

Status
Not open for further replies.

44nato44

Programmer
Dec 12, 2008
115
NL
Hi

I am trying to find a way to add a column name, so it contains two words.

dbs.Execute "ALTER table ThisTable add Gender Wa char(1);"

With the above code I try toadd the column Gender Wa, but it will not let me. It only add Gender.

If I try 'Gender Wa' then it adds the column 'Gender Wa', so also not the preferred solution.

I hope somebody has a way this can be done ?
 
dbs.Execute "ALTER table ThisTable add [!][[/!]Gender Wa[!]][/!] char(1);"

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I would actually encourage you to NOT name your column with 2 words or even reserved words. The problem with 2 words as column names is that you will be stuck forever using the square brackets. In my opinion, the square brackets make the code more difficult to read. Instead, I suggest you remove the space "GenderWa", or use an underscore "Gender_Wa". In either case, it will prevent you from having to use the square brackets everywhere (in your sql code) that references this new column.

Please understand that this is only my opinion.



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I second George's opinion - db object names (tables, queries, views, forms..etc) should always be single words (or muliple words separated with an underscore or caps).

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
This is true, but I needed to build an extract for a load file for another system where they have made column names with spaces :(

If it was me then I would not have spaces, either underscore or two words put together.

Thanks all for your input
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top