Solved

Joining two cells togeter on tables in SQL 2005

Posted on 2010-08-30
6
256 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
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now