473,500 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Specify Allow Zero Length String for Field

NeoPa
32,557 Recognized Expert Moderator MVP
I've searched around for help on this but everything I find seems to be a discussion about the relative benefits of using, or not using, this setting.

I want to specify in SQL Server that ZLSs are not acceptable in the field whether or not NULLs are allowed. If ever I have to deal with an empty-looking value I want to know it's NULL rather than a ZLS.

The version of SQL Server is 2012 R2 Express (11.0.2100.60).

Any help on this is greatly appreciated.
Mar 19 '15 #1
4 1787
Rabbit
12,516 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE [schema_name].[table_name]
  2. ADD CONSTRAINT [constraint_name]
  3. CHECK (LEN([field_name]) > 0 OR [field_name] IS NULL)
If by zero length, you mean count trailing spaces as part of the length, use DATALENGTH(). If you don't want to count trailing spaces as part of the length, use LEN().
Mar 19 '15 #2
NeoPa
32,557 Recognized Expert Moderator MVP
Thanks Rabbit :-)

I probably should have included the version in the question so I'll fix that.

I can make do with the SQL as I'll mainly be creating scripts to set up the tables anyway, but if you know, I'd certainly be interested to know how to do this from within Management Studio too.

Just to be clear - I am looking for a setting which maps across to Access as the property named "Allow Zero Length". If it isn't possible then that's weird but I can deal with it. I possibly should have written the original question more clearly. It's certainly helpful to know I can design a simple constraint for it/them.
Mar 20 '15 #3
Rabbit
12,516 Recognized Expert Moderator MVP
I don't know of a check box option for ZLS like there is in Access
Mar 20 '15 #4
NeoPa
32,557 Recognized Expert Moderator MVP
Cheers.

I'll experiment with whether or not the constraint causes Access to recognise it as Allow Zero Length or not. At least I know what limitations I'm working within. Thanks for the help.
Mar 20 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7138
by: William Kossack | last post by:
We ran into a problem loading access where tables where if we did not select the property allow zero length we got an error message when loading data with some empty values. We are now ramping...
6
2594
by: Rob Fielding | last post by:
Hi, We're currently experiencing a problem where SQL statements are failing when entring a '' for not not-null integer columns: ERROR: pg_atoi: zero-length string This was discovered just...
2
5068
by: William Kossack | last post by:
How do you set the "Allow Zero Length" option for an access field during an sql create query?
1
2182
by: Guadala Harry | last post by:
What do to about conversion to decimal type when blank is allowed? The situation is this. In the UI there is a textbox into which users can enter a value which is supposed to be a dollar amount....
2
5888
by: johnb41 | last post by:
I have a simple form that has a bunch of textboxes that show data from a dataset table. When I "Add" a record with BindingManagerBase.AddNew(), all the textboxes go blank, so I can add a new...
10
4557
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
2
5297
by: zeljko.prince | last post by:
This is a copy from http://forums.mysql.com/read.php?10,73797,73797#msg-73797. Perhaps someone on this group will know the answer. Given the following table: CREATE TABLE foo(field VARCHAR(20)...
3
11190
by: Coll | last post by:
I inherited a database. On one of the forms, a bunch of fields on the form are to be updated with data from a combo box containing many columns after one particular field is updated. I'm receiving...
3
2169
by: angi35 | last post by:
I'm having a zero-length string problem... Hoping someone can help. (This is in Access 2000.) In FormA, I have a button that opens FormB with OpenArgs. In FormB, the OpenArgs are translated into...
1
8738
by: munkee | last post by:
I have just been looking through a few websites and found massive debates around Allow Zero Length strings within a field. I have read that having the property set to yes can make your queries run...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7235
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5491
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4614
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3108
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1431
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
317
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.