Single repository table for all T-SQL coulmns aliases

Harreni
Harreni used Ask the Experts™
on
Hi Experts,


- I want to have a master table for all columns aliases that exists in my stored procedures so, I can change the alias in one place instead of changing it in each stored procedures, because my data is in Arabic language and my table columns names are in english language and want to display the columns names in Arabic.

Please provide me an example in how to achieve that?


Thanks a lot

Harreni
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Docteur_ZDatabase Engineer

Commented:
I know you won't like the answer, but SQL is not the place where you should do stuff like this.
What your asking is to make every statement in your stored procedures to be dynamic.
Keep stored procedures static, read the dictionnary in your application - in an array for example, then map the column names to the dictionnary in your application.
Jose TorresCertified Database Administrator
Commented:
You might want to consider creating a view with the aliases in the view.
Then using the view in your stored procedure.
Jim HornSQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015

Commented:
Agreed.  SQL server does not have an automated way to utilize multiple object name aliases in code, so If this means that much then perhaps the table and column names should be changed to Arabic.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Thanks a lot Docteur_Z & Jim for your replies.

Mr. Jose,
What's the benefit from creating a view for my stored procure? Why not directly modify the stored procedure instead?
IT Engineer
Distinguished Expert 2017
Commented:
Work with views instead of tables performing this way a virtual table layer.
Example:
CREATE VIEW vTableName
AS
SELECT EnglishCol1Name AS ArabicCol1Name,
    EnglishCol2Name AS ArabicCol2Name,
...,
EnglishCol99Name AS ArabicCol99Name
FROM TableName

Open in new window

So in your Stored Procedures replace TableName with vTableName and the query will return the Arabic column names instead of English ones.
Jose TorresCertified Database Administrator

Commented:
Vitor's example is spot on.

Author

Commented:
Thanks a lot experts.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial