473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Force Column Alias with 'AS' keyword

Hello,

as we know we use use 'AS' keyword for column aliasing but even though if you wont use 'AS' keyword for column alias you can still be able to create alias
eg.1. select Column1 as Col1 from SomeTable
eg.1. select Column1 Col1 from SomeTable
Above both queries results with column alias as Col1

But while writing huge stored procedure, if we miss a comma(,) between two columns then latter column name becomes alias for other column.
eg. Select column1,
Column2,
Column3
Column4
So this will result in 3 columns Column1,Column2 and Column4. Since Column3 has no comma Column4 acts as alias. How can we avoid this (Please dont tell me to be more carefull) is there are references is available to force alias to presented with AS keyword or any other method is present
Apr 12 '13 #1
4 2012
Rabbit
12,516 Expert Mod 8TB
I don't know of a setting off the top of my head that requires the SQL interpreter to require using AS when defining an alias.
Apr 12 '13 #2
NeoPa
32,556 Expert Mod 16PB
venkatesh2j:
(Please dont tell me to be more carefull)
Ultimately that's all you can do. You could possibly write a macro that checks your SQL, but that wouldn't be too straightforward. Parsing SQL is a complicated job with many syntax rules to reproduce.

As Rabbit says, I'm pretty sure there is no option within SQL to disable this particular item within SQL syntax. After all, there are published standards on SQL and that syntax is part of those standards.
Apr 13 '13 #3
thanks chaps!! gave a try might some people has any work around..
Apr 13 '13 #4
NeoPa
32,556 Expert Mod 16PB
Suck it and see.

If it does what you expect then it's not likely to have any extraneous ALIASes.
Apr 13 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Andrew | last post by:
With command-line interface ( 3.23.37, UNIX Socket ) all is well with column aliasing. However, column aliases disappear in Excel, over ODBC, when there are multiple (joined) tables in the query. ...
2
by: Saiyou Anh | last post by:
I know passing table/column name as parameter to a stored procedure is not good practice, but sometimes I need to do that occasionally. I know there's a way can do that but forget how. Can someone...
6
by: DC | last post by:
Is there a way to use a column alias in an another calculation within the same query? Since I am using some long and complex logic to compute total1 and total2, I don't want to repeat the same...
2
by: sks | last post by:
Hi all, Is possible to retrieve all columns and alias them all at once. Eg, normally you would write select * from products which would return id | name | price ----------------------- 1...
1
by: Dougeth | last post by:
Hi All, I have having a problem conducting an aggregated function off an alias column I create on the fly. I get an error saying SearchType is an invalid column name yet when I remove the Count...
4
by: Sparta71 | last post by:
Hello, I'm pretty new to this, but I'm working on an MS Access DB and I'm trying to create a query that will accept a column name as a parameter. The table is set up to show an employees base...
0
by: Joe Meng | last post by:
Greetings, I've seen this question asked and answered here, just not completely yet. I'm wondering how to use a column value as a table name in another query. So far it's looking like you must...
1
by: Rahul Babbar | last post by:
Hi, I tried to generate the query plan for a query using a tool called Aqua Data Studio. It showed the explain plan and showed that a particular scan on a particular table was taking a long...
1
by: Plamen Ratchev | last post by:
You cannot use a column alias in the definition of another column. The solution is as you found to repeat the expression. Alternative solution is to define the first column in one CTE (or derived...
12
by: sheppardpg | last post by:
I have a a query with a column that needs to have a data type of Memo, which I am able to achive with this function; Public Function MEMO() MEMO (COMMENTS) End Function I want to define the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.