Wednesday, March 21, 2012

Rewrite to Sargable

Is there a way to rewrite either of the following where clause items to allow
them to be SARGABLE?
1. ISDATE(Team.TextValue) = 1 -- Ensure that the value in the TextValue
field is a date. TextValue datatype is varchar(25).
2. LEFT(Team.Codes, 1) <> '-' -- Exclude the Codes that begin with a '-'.
Codes datatype is varchar(10).
--
Message posted via http://www.sqlmonster.comFor #2, try:
Team.Codes not like '-%'
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
.
"cbrichards via SQLMonster.com" <u3288@.uwe> wrote in message
news:6a089625d4de6@.uwe...
Is there a way to rewrite either of the following where clause items to
allow
them to be SARGABLE?
1. ISDATE(Team.TextValue) = 1 -- Ensure that the value in the TextValue
field is a date. TextValue datatype is varchar(25).
2. LEFT(Team.Codes, 1) <> '-' -- Exclude the Codes that begin with a '-'.
Codes datatype is varchar(10).
--
Message posted via http://www.sqlmonster.com

No comments:

Post a Comment