You are here:

MS SQL/Question regarding SQL

Advertisement


Question
In SQL, is there any query to convert the column names from lower case to upper case.

For example there is a table called "Persons" and in that I have created some data. In the persons name column I have specified the persons name in lower case letters.

Actually I got this question in an interview for which I was clueless.

Perons

Person ID  Person Name
1          abc
2          xyz  
3          asd

And the interviewer said the output should be as follows:

Persons

Person ID    Person Name
1          ABC
2          XYZ
3          ASD

My doubt is how to convert the Person Name column to upper case. Is there any query?  Please help me with this.

Answer
Hi Venkat

Please use "UPPER".

SELECT UPPER (PersonName) AS PersonName
FROM Persons

http://msdn.microsoft.com/en-us/library/ms180055.aspx

Also have a look at other string functions, might help you in your interview.

http://msdn.microsoft.com/en-us/library/ms181984.aspx


Thanks
Mohit

MS SQL

All Answers


Answers by Expert:


Ask Experts

Volunteer


Mohit Nayyar

Expertise

Microsoft SQL Server: T-SQL development (stored procedures, triggers, functions), Database optimization, performance tuning, high availability (Clustering, Log Shipping, Mirroring, Replication), scalability, SQL Server migration (Sybase/Oracle to SQL Server), SSIS/DTS, Data Warehousing (Kimball Methodology), ETL (SSIS), Cube (SSAS), Reporting Services (SSRS), database modeling, database administration, Security implementation and typically anything related to Microsoft SQL Server.

Experience

With over 10 years of experience in Database Administration, Development, Business Intelligence solutions and managing enterprise level database solutions based on Microsoft SQL Server.
Publications
IT Magazine: ASP, SQL

Publications
IT Magazine: ASP, SQL
SQLServerCentral.com

Education/Credentials
MCA (Masters)

Awards and Honors
Brainbench Certified: RDBMS
MCTS: DBA/Developer/BI for SQL Server 2005/SQL Server 2008
MCITP: DBA/Developer/BI for SQL Server 2005/SQL Server 2008
MCDBA: SQL Server 2000
MCP: SQL Server 6.5

©2016 About.com. All rights reserved.