Reputation:
I am using a query in vb.net, database is Access I need alias of query like sql but the query return me column alias and also ' '
SELECT COLUMN1 AS 'FIRST NAME'
I expect the result to be a field called FIRST NAME
but it returns the string "FIRST NAME"
Is there is any way if return me the field FIRST NAME
instead of "FIRST NAME"
Upvotes: 3
Views: 17048
Reputation: 1
Note the following in Access 2003:
This is ok:
SELECT Table1.AText AS [First Name] FROM Table1;
But this is NOT ok: the space gets removed, becoming First(Name):
SELECT Table1.AText AS [First (Name)] FROM Table1;
But then, these are all ok: no spaces get removed:
SELECT Table1.AText AS [The First (Name)] FROM Table1;
SELECT Table1.AText AS [The (First) Name] FROM Table1;
SELECT Table1.AText AS [(First) Name] FROM Table1;
SELECT Table1.AText AS [(First) (Name)] FROM Table1;
Upvotes: 0
Reputation: 91326
This question is tagged ms-access, and in Access it is easy to discover what is allowed in queries by using the query design window. For more elegant and advanced queries the window is not suitable, but for this it is a useful tool.
SELECT Table1.AText AS [First Name]
FROM Table1;
Upvotes: 7
Reputation: 48139
no, Typically, column names should never have embedded spaces within them. Some people do, but not recommended. For the SQL engines to recognize such columns, they explicitly need the tic marks around the column to understand that its not two words, but one column name. Even though the the column name without the space could come back as FirstName, whatever your output, you can format reports and such however else you want.
Upvotes: 1