Solved

Getting LEN of field type ntext

Posted on 2002-07-29
5
1,654 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 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 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 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

726 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