Solved

Joining two cells togeter on tables in SQL 2005

Posted on 2010-08-30
6
259 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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