Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2007

Tip: Looking for answers? Try searching our database.

SQL: Select a column name "Short Name"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ali - 29 Oct 2007 13:01 GMT
I cannot select a column if it has a space.  

------------------------------------------------------------------------------------------
For example, i have a table:

Short name          Code                   Year_Produced
ABA                       1001                    2005
BBB                        1544                    2001
CCC                       1002                    2000
------------------------------------------------------------------------------------------

I cannot select "short name" because there's a space in between

While i can select "Year_Produced" , because there's underscore("_") in
between.

------------------------------------------------------------------------------------------

How can I write an SQL to select name with space in between. Using quote ?
How ?

please kindly show me an example !

thank you , expert !!

Signature

Allen Phailat Wongakanit

John Spencer - 29 Oct 2007 13:45 GMT
In Access SQL you use square brackets if the column name has a space, is a
reserved word, or uses characters other than the Underscore, Letters, and
numbers.

SELECT [Short Name], Code, Year_Produced, [22],  [Time], [All-Source]
FROM SomeTable

Explanation of why brackets.
Short Name  has a space
22 is all numbers
Time is a reserved word (current system time)
All-Source is hyphenated and would be seen as a math expression (subtract
column "Source" from column "All") and ALL is a reserved word also.
Signature

John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

>I cannot select a column if it has a space.
>
[quoted text clipped - 20 lines]
>
> thank you , expert !!
ali - 30 Oct 2007 03:51 GMT
Perfect explaination, Straight to the answer . Thank you !

Signature

Allen Phailat Wongakanit

> In Access SQL you use square brackets if the column name has a space, is a
> reserved word, or uses characters other than the Underscore, Letters, and
[quoted text clipped - 33 lines]
> >
> > thank you , expert !!
Tagory Torres - 08 Nov 2007 16:32 GMT
Guys,

I tried to use this, but it's not work with character "?"! Is there a solution to this problem?

I can't change the column name.

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
John Spencer - 08 Nov 2007 16:52 GMT
Can you be clearer?  What is the field name (column name)  that you can't
specify?

Normally if the field name contains characters other than letters, numbers,
and underscores, then you refer to the field as bracket Field Name bracket
and to fully refer the name you use bracket table name bracket dot bracket
field name bracket.

[Some Table #].[Some field?]

Or in some cases (only one table in a query)
[Some field?]

Signature

John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> Guys,
>
[quoted text clipped - 5 lines]
> EggHeadCafe - .NET Developer Portal of Choice
> http://www.eggheadcafe.com
Dale Fye - 29 Oct 2007 13:51 GMT
My advise, never put spaces in the names of anything in Access.  If you feel
you need the space for readability, use an _ to separate words.  You can
select the field by wrapping it in brackets.

SELECT [Short name], Code, Year_Produced
FROM yourTable

HTH
Dale
Signature

Don''t forget to rate the post if it was helpful!

Email address is not valid.
Please reply to newsgroup only.

> I cannot select a column if it has a space.  
>
[quoted text clipped - 20 lines]
>
> thank you , expert !!
Jason Lepack - 29 Oct 2007 14:22 GMT
Select [Short name] from [Your Table]

> I cannot select a column if it has a space.  
>
[quoted text clipped - 23 lines]
> --
> Allen Phailat Wongakanit
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.