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 |
|
chapo
Starting Member
39 Posts |
Posted - 2008-04-11 : 08:09:55
|
I have a view where I'm trying to populate a field base on the values on the USEJSLOAD field. The USEJSLOAD it's a (bit,null) field and there are only two types of values on it they are 'True' or 'False' so if it's true grab the data from one field else the other field. When I try to run the view I get the following error, 'Conversion failed when converting the varchar value '1-1S ' to data type int. Any help would be greatly be appreciated.(CASE WHEN dbo.ftlibr_base.USEJSLOAD = 1 THEN dbo.trn_transport.TRN_LOADNODERIVED ELSE trn_transport.TRN_DISPATCHNO END)Sample data:ftlibr_base Work_Order | USEJSLOAD1 | True2 | False3 | Truedbo.trn_transportWork_Order | TRN_LOADNODERIVED | TRN_DISPATCHNO1 | 1-1S |12 | 4-2S |103 | 1-30S |2I would like: Work_Order | Load #1 | 1-1S2 | 103 | 3-20S |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-11 : 08:28:03
|
All the resulting expressions in CASE must be of same data type.(CASE WHEN dbo.ftlibr_base.USEJSLOAD = 1 THEN dbo.trn_transport.TRN_LOADNODERIVED ELSE cast(trn_transport.TRN_DISPATCHNO as Varchar(10)) END) Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
chapo
Starting Member
39 Posts |
Posted - 2008-04-11 : 09:53:19
|
| Thank you |
 |
|
|
|
|
|