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 |
|
sduclosson
Starting Member
6 Posts |
Posted - 2009-03-16 : 10:28:55
|
| Hello I´m working in a multi-database system wich already works with Access and Oracle and it´s my job to make it compatible with SQL Server 2005.Doing this I encountered a problem, it is related to the implicit conversion that SQL Server does when combining a varchar variable with an integer variable. I have several SQL queries that combine those types of variables so casting them all it´s not a viable option. I would like to know if there is a way of preventing SQL Server from doing that conversion or changing it to varchar without having to modify the queries. I´m using SQL Server Management studio 2005.Thank you in advance. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-16 : 10:37:32
|
| You need to use cast them explicitly using cast or convert or do some dummy operations to impose implicit conversion. if you can show some data sample, i'll explain in detail. |
 |
|
|
sduclosson
Starting Member
6 Posts |
Posted - 2009-03-16 : 11:08:18
|
| Here is an example:Rem_Mov_o_c.RemMovOCObraCodDes + '~' + Rem_Mov_o_c.RemMovOCLocCodDes + '~' + RemMovOCCabNroDes as destinoRem_Mov_o_c.RemMovOCObraCodDes and Rem_Mov_o_c.RemMovOCLocCodDes are varcharRemMovOCCabNroDes is smallintthe proble is that SQL Server converts everything to smallint, if I change the query to cast(Rem_Mov_o_c.RemMovOCObraCodDes + '~' + Rem_Mov_o_c.RemMovOCLocCodDes + '~' + RemMovOCCabNroDes as varchar) as destino works fine, the problem is that the system I´m working on have hundreds of queries with similar statements and would be to big of a change to cast them all. The company I work for it´s not willing to make that change because of the time required to apply and test the changes, so I need to find a way to solve the problem without changing the queries.Thank you for your answer. |
 |
|
|
|
|
|