Solved

Joining two cells togeter on tables in SQL 2005

Posted on 2010-08-30
6
263 Views
Last Modified: 2012-05-10
Hello experts I have a fun project that I have inherated.... it involves a table that was built 3 years ago and the designer used CHAR and not VARCHAR.... here is my situation

Semester char(20)
SchoolYear int.

My current statement
select Semester + SchoolYear as SemesterSchool from Schedule

My current Error
Conversion failed when converting the varchar value 'F2UU                ' to data type int.

1. How do I corret the spacing trim().
2. All I need to do is join these two collums into one

Restraints...
1. Cant change the original tables in the database
2. Boss is on me... any help?
0
Comment
Question by:HawaiiDragon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Assisted Solution

by:birdmian
birdmian earned 100 total points
ID: 33562750
Try like this:

SELECT rtrim(Semester) + ' ' + convert(char(4), SchoolYear)
0
 
LVL 4

Expert Comment

by:joeyw
ID: 33562783
try the convert statment

select convert(varchar, Semester)  + rtrim(SchoolYear) as SemesterSchool from Schedule

0
 
LVL 16

Assisted Solution

by:vdr1620
vdr1620 earned 100 total points
ID: 33562788
Try
SELECT rtrim(Semester) + ' ' + convert(Varchar(4), SchoolYear)
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 4

Accepted Solution

by:
joeyw earned 300 total points
ID: 33562791
oops had your fields backwards

try the convert statment

select rtrim(Semester)  + convert(varchar,SchoolYear) as SemesterSchool from Schedule
0
 
LVL 4

Expert Comment

by:parthmalhan
ID: 33564442
Try the Following Code:

select ltrim(rtrim(semester))+ltrim(rtrim(convert(varchar,schoolyear) as 'Alias' from Schedule

let me know if you need any more help
0
 

Author Closing Comment

by:HawaiiDragon
ID: 33567525
All solutions worked however Joeyw's worked the best as removing all trim form the fileds as well as joining them in the correct way. Thank you all!!!!!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question