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 |
|
nerdygirl61
Starting Member
21 Posts |
Posted - 2011-10-01 : 18:32:41
|
| When running the following code I get error 'Msg 245, Level 16, State 1, Line 2Conversion failed when converting the varchar value '45`' to data type int.'tp.program_code is varchar(50)sx.program_code is varchar(15)I checked the data in both tables and 45' does not exist in either one. Why is it trying to convert this to int? Is it because the size doesn't match?SELECT TOP 100000 sx.program_codeFROM staff_tx_history as sx ,table_program_definition as tpWHERE sx.date_of_service >= '7/1/11' and sx.date_of_service <= '7/31/11' and sx.duration > 0and sx.program_code <> 'CO'and sx.program_code = tp.program_code |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-10-01 : 18:52:11
|
| Could it be that sx.duration is not an INT column? Perhaps there is a funky value in there? Otherwise:Are either staff_tx_history or table_progarm_definition VIEWs? Do any of the underlying tables have triggers on them?Be One with the OptimizerTG |
 |
|
|
nerdygirl61
Starting Member
21 Posts |
Posted - 2011-10-01 : 19:10:54
|
That's it, sx.duration is varchar, changed it to ...and sx.duration > '0'...and it runs. Will this skew the results? Do I need to convert it?Thank YOU! |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-10-01 : 19:38:22
|
| Conversion failed when converting the varchar value '45`' to data type int.'is not the same as 45' |
 |
|
|
|
|
|