Solved

How to compare the data of smallint with varchar

Posted on 2004-10-05
6
327 Views
Last Modified: 2006-11-17
Hello, I have one field with type of smallint, and want to compared to another filed with type of varchar in differet table, both two fields have same meaning, now i want to compare them, how can i do a conversion, that say, Table A,field1: Line_nbr, varchar; Table B, field2:req_line_nbr. how can i do the comparsion of req_line_nbr with line_nbr? what function should i use? Thanks
0
Comment
Question by:shyline777
  • 2
6 Comments
 
LVL 4

Expert Comment

by:strangelynormal1
ID: 12230665
SELECT *
FROM [Table A] a
         ,[Table B] b
WHERE CONVERT(VARCHAR(20),a.Line_nbr) = b.req_line_nbr
0
 

Author Comment

by:shyline777
ID: 12237988
i did the convert and only return 18 which should be 42, i found the problem coused by my extract function LEFT which Return TAB character clude, so can you tell me how can i extracted the characters before a TAB used as a delimiter in a data field?  Thank you so much
0
 
LVL 4

Accepted Solution

by:
strangelynormal1 earned 50 total points
ID: 12239724
Okay, let's assume that the field only has tab as a possible extra character.

SELECT *
FROM [Table A] a
         ,[Table B] b
WHERE a.Line_nbr = CONVERT(SMALLINT,REPLACE(b.req_line_nbr,CHAR(9),''))
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

746 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

16 Experts available now in Live!

Get 1:1 Help Now