Solved

nText field pulling blank records when I use Is Not Null

Posted on 2006-11-17
16
656 Views
Last Modified: 2008-01-09
Is there something else I can use to check this?  I have a linked SQL table in access.  The SQL field is a ntext field.  When I run a query and say Is Not Null it is still in some cases pulling a blank record.  Thanks all
0
Comment
Question by:sbornstein2
  • 9
  • 6
16 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 17967487
Is the record blank or null?
Check whether or not it is an empty string    column=''.
Or perhaps it has been padded RTRIM(column)=''.
0
 

Author Comment

by:sbornstein2
ID: 17967557
ya well I tried in access "Is Not Null and <> """.  But I get an error when I say the <> "" in access against that field.
0
 

Author Comment

by:sbornstein2
ID: 17967576
it is blank I beleive
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 29

Expert Comment

by:Nightman
ID: 17967616
Blank is not null, but empty string. Do you have access to Query Analyser?

If so, run this:

SELECT * FROM yourTable WHERE RTRIM(YourColumn)=''
0
 

Author Comment

by:sbornstein2
ID: 17967766
I cant access Query Analyzer right now unfortunatly.  I can only link to the table.  It is showing in design a memo field converting the SQL field Text to say that.  But I return approx 10 or so records that are showing my text field as blank in the query when using the Is Not Null only.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17967786
Then those records are not null, but probably empty string.

Post your query here and I'll see if I can modify it for you.
0
 
LVL 28

Expert Comment

by:imran_fast
ID: 17971126
hi,
Is it showng <logn text> in enterprise manager? Can you verify that?
0
 

Author Comment

by:sbornstein2
ID: 17974875
it is just showing blank in Enterprise Manager and I dont want to change the datatype to a varchar(4000) etc. because it is setup using replication right now. I dont want to mess with that.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17974882
So run this query in Query Analyser:
SELECT COUNT(*) FROM yourTable WHERE RTRIM(YourColumn)=''

What does that return?
0
 

Author Comment

by:sbornstein2
ID: 17974895
anytime I use the '' it never works on a Text field.  I am in SQL now and it is not ntext it is a text field.  Your query above returns:

Server: Msg 8116, Level 16, State 2, Line 1
Argument data type text is invalid for argument 1 of rtrim function.

I open the table and it is showing blank or an empty string.
0
 
LVL 29

Accepted Solution

by:
Nightman earned 125 total points
ID: 17974904
Do this then
SELECT COUNT(*) FROM yourTable WHERE RTRIM(CAST(YourColumn as nvarchar(4000)))=''
0
 

Author Comment

by:sbornstein2
ID: 17974915
4850 rows out of about 9K.  So looks like there is quite alot.
0
 

Author Comment

by:sbornstein2
ID: 17974916
should I try an update to Null on these?
0
 

Author Comment

by:sbornstein2
ID: 17974921
ya that worked I did an update to null where those came up and it now works.  Thanks for your help though.  I wonder what I can do for the future for this other than changing the datatype
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17974937
Identify how it became '' in the first place. i.e. prevent unexpected data from coming in to your database from the UI by validating it.

Good to see it's working now.
0
 

Author Comment

by:sbornstein2
ID: 17974939
yup thanks Nightman.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question