Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

speed up LEN(RTRIM(LTRIM(ERR))) > 0??? 1

Status
Not open for further replies.

Will192

Technical User
Nov 15, 2002
111
US
ERR is a column of char(255)

How can I speed up this reference?

LEN(RTRIM(LTRIM(ERR))) > 0

I need to find out if there is anything in ERR that is not blanks. This query is going to be ran thousands of times a day on nonstatic data, so precalculating to another table is not a valid option.

I haven't tried to convert ERR to a varchar(255), would this speed up LEN(RTRIM(LTRIM(ERR))) > 0??

Thanks in advance for any responses to this post.
 
why not creating a constraint instead?
Saves a lot of headaches

create table testLen (SomeField varchar(50),CONSTRAINT chk_Len CHECK (LEN(RTRIM(LTRIM(SomeField))) > 0 )
)

--now try this
insert into testLen
select ' '

and here we go:
Server: Msg 547, Level 16, State 1, Line 1
INSERT statement conflicted with COLUMN CHECK constraint 'chk_Len'. The conflict occurred in database 'pubs', table 'testLen', column 'SomeField'.
The statement has been terminated.


That's it

Denis The SQL Menace
SQL blog:
Personal Blog:
 
I need to allow the field to be blank also. The column is for error text. There may not be an error with the row.

What I need is the fastest way to see if there is anything in the column besides blanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top