Solved

Joining two cells togeter on tables in SQL 2005

Posted on 2010-08-30
6
260 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 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