Solved

nText field pulling blank records when I use Is Not Null

Posted on 2006-11-17
16
650 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
 
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now