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 |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2009-07-14 : 08:34:33
|
A SQL Server 2005 table has two fields. Both are varchar (100).I need to alter the first field from varchar (100) to text and then concantenate both fields if the second field contains any text.I used:USE debtGOUPDATE debtorSET KeyInformation = Cast (KeyInformation AS varchar) + NextLegalActionWHERE LEN(NextLegalAction) > 0 However, there appears to be an implied field length of 30 characters for the varchar casting as it has truncated the first field's contents when performing the cast operation.How should I have written my sql query to avoid this please? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-14 : 08:36:51
|
| UPDATE debtorSET KeyInformation = Cast (KeyInformation AS varchar(100)) + NextLegalActionWHERE LEN(NextLegalAction) > 0MadhivananFailing to plan is Planning to fail |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2009-07-14 : 10:15:29
|
| Many thanks. I've realised that myself now.Would have saved me a lot of hassle if I had thought of it before.Note to self: when it reaches midnight, and you're on the day shift, stop coding and GO HOME. :) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|