Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unexpected concatenated fields
Message
 
 
To
12/03/2003 06:22:23
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00764678
Message ID:
00764741
Views:
27
This message has been marked as the solution to the initial question of the thread.
Mark,

The default lenght for char and varchar in CAST is 30 characters. That what causes truncation in the fourh part of expression. Specifaing varchar lenght explicitly should fix it.
CAST(LEFT (RTRIM(dbo.[section].sect_desc), 25) + ' / ' + 
  LEFT (CAST(dbo.heading.head_desc AS VARCHAR), 25) + ' / ' +
  LEFT (CAST(dbo.item.item_desc AS VARCHAR), 25) + ' / ' + 
  LEFT (RTRIM(CAST(dbo.subitem.sub_desc AS VARCHAR(50))), 50) AS varchar(600))
I prefer always specify lenght in char/varchar so I don't have to worry about defaults.

>In the following expression
>the field returned is truncated unexpectedly to 120 characters long.
>
>CAST(LEFT (RTRIM(dbo.[section].sect_desc), 25) + ' / ' + LEFT (CAST(dbo.heading.head_desc AS VARCHAR), 25) + ' / ' +
>LEFT (CAST(dbo.item.item_desc AS VARCHAR), 25) + ' / ' + LEFT (RTRIM(CAST(dbo.subitem.sub_desc AS VARCHAR)), 50) AS varchar(600))
<snip>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform