
October 27th, 2004, 01:36 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Use DATALENGTH to find length of ntext or text data
Quote: | Originally Posted by Chauzer i have a trigger on a table right now... when fields are inserted, theres a text field inserted and i want to check if that text field = '' (the empty string, not NULL) and if it doesn't equal that, then perform some row updates on other tables, but if it is empty, to not do anything else in the trigger... right now i have this:
Code:
IF ((SELECT Note FROM XATPoDetail WHERE ReqNbr = (SELECT ReqNbr FROM Inserted)) LIKE(''))
Note is the text field, XATPoDetail is the table where its being inserted into. I had to do the select FROM the table because it wouldn't let me select a text data type from the "Inserted" virtual table
but it tells me me "Error 279: The text, ntext, and image data types are invalid in this subquery or aggregate expression"
thanks |
How about using DATALENGTH(Note) ? This will give you the number of bytes in the field. In the case of text, the number of bytes is the number of characters.
You coulc use DATALENGTH(Note) > 0 instead of comparing to a null string.
|