?
Solved

Getting LEN of field type ntext

Posted on 2002-07-29
5
Medium Priority
?
1,668 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

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 200 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 143

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.
Suggested Courses

771 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