Solved

nText field pulling blank records when I use Is Not Null

Posted on 2006-11-17
16
643 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Restore Script - Syntax Error 8 75
t-sql complement 8 32
How to find duplicates in SQL Server 3 22
Test a query 23 17
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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 shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

758 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

23 Experts available now in Live!

Get 1:1 Help Now