Solved

Getting LEN of field type ntext

Posted on 2002-07-29
5
1,650 Views
Last Modified: 2012-06-22
Hi,

SELECT propertyID FROM properties WHERE LEN(propertyDescription) > 200

gives me the result

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

So maybe I can't len ntext fields?

Any one know of a work around?

Ben
0
Comment
Question by:bendecko
  • 2
  • 2
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7187237
use datalength() function:

SELECT propertyID
FROM properties
WHERE DATALENGTH(propertyDescription) > 200

CHeers
0
 
LVL 19

Accepted Solution

by:
Rimvis earned 50 total points
ID: 7187244
BTW, ntext is Unicode text, so it takes 2 bytes to store one character.
So, if DATALENGHT(propertyDescription) = 200, actual text lenght would be only 100.

Your query should look like this:

SELECT propertyID
FROM properties
WHERE DATALENGTH(propertyDescription) > 400
0
 
LVL 1

Author Comment

by:bendecko
ID: 7187279
Great!

angelIII I think I'm going to split the point on this one between you two as if Rimvis hadn't suggested his comment I'd have been sratching my head for ages!!!!

No problem I hope?

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7187288
Give all the points to Rimvis, his answer was complete!
CHeers
0
 
LVL 1

Author Comment

by:bendecko
ID: 7187387
That very noble of you angelIII I'll sort you out next time.

Ben
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

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.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

809 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