Single repository table for all T-SQL coulmns aliases

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
HarreniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Docteur_ZCommented:
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 AdministratorCommented:
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 DudeCommented:
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.
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

HarreniAuthor 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?
Vitor MontalvãoMSSQL Senior EngineerCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jose TorresCertified Database AdministratorCommented:
Vitor's example is spot on.
HarreniAuthor Commented:
Thanks a lot experts.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.