Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Trudye
Posting Yak Master
169 Posts |
Posted - 2008-05-08 : 13:16:23
|
| Hi Guys, I am experiencing weird resultsSELECT DSNew, DTTM, RQDTFROM dbo.Feb INNER JOIN DMSEFL ON ACTR = DSNew where cast(DSNew as varchar(20)) = cast(ACTR As varchar(20))If I run the above query I get zero recs back. If I substitute a Value then I get the desired results (ie. where DSNew = '93235500') or if I enter (ACTR = '93235500') or if I put (where DSNew = '93235500' AND ACTR = '93235500')Can anyone suggest a reason why this is happening. I know the records exist on both tables I ran the query in Acess and got the desired resutls. Thank you,Trudye |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-08 : 13:23:11
|
| Whats the purpose of WHERE clause? Havent you given the same condition on the ON clause of JOIN? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-08 : 13:24:25
|
| What data type is DSNew? What data type is ACTR?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
Trudye
Posting Yak Master
169 Posts |
Posted - 2008-05-08 : 13:30:00
|
| Thanks guys for responding so quickly.visakh16, I put in the where clause because I was grasping at straws.one is text and one is varchar, both are 20 bytes |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-08 : 13:55:09
|
| Not sure if its because of text data. Anyways, can you try like this?SELECT DSNew, DTTM, RQDTFROM dbo.Feb INNER JOIN DMSEFL ON SUBSTRING(ACTR,1,20) = SUBSTRING(DSNew,1,20) |
 |
|
|
|
|
|
|
|