*
The moose likes Beginning Java and the fly likes Controling Text Length Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Controling Text Length" Watch "Controling Text Length" New topic
Author

Controling Text Length

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
I have the following code in an SQL update statement. If the string is lees tahn 2000 charactors I get an error. What syntax can I use to keep the string under 2000 and at the same time not cause an error?

Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2173
    
  47
You need to check the length of the string so that the second argument of substring is either the max length of the string or 2000 which ever is the smaller eg:



Note: this will still fail if 'signhist' is null so you may need to also check for that
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Controling Text Length
 
Similar Threads
Varchar(2000) -- Casting
Unicode Character ??
error in wsdl
MS SQL Server and alue can not be converted to requested type
HELP please with SQL Server