I was under impression that declaration of char(4) can store only values of exact length of 4 characters. However I was able to insert empty string and strings of less characters than 4.
Is there some datatype that will only accept string of declared length? Strings with less characters should be refused. Or I'm left only with application logic to check desired string length?

9 Years
Discussion Span
Last Post by peter_budo

I think u have to apply some simple logic ... there is no specific keyword to accept exact string length...


it will allow up to 4

i would either go with some client side code, or used a stored procedure that will check the length before inserting and reject the data

this does sound more like a business rule, so i would say keep it in the business logic portion of the app

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.