SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Deprecated]Function call can be extracted from the WHERE clause to avoid unnecessary table scan.


Deprecated]Function call can be extracted from the WHERE clause to avoid unnecessary table scan.

Author
Message
Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28006 Visits: 4895
The DATEADD function is Deprecated.

What is the best way to achieve the same results without adversely impacting on performance?


WHERE CD_DW_INSERT_DATE > DATEADD(DAY, -7,@Date);




Thanks.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Lowell
Lowell
SSC Guru
SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)SSC Guru (74K reputation)

Group: General Forum Members
Points: 74781 Visits: 40985
dateadd is not deprecated.

Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28006 Visits: 4895
Lowell (1/16/2014)
dateadd is not deprecated.


I run it through ubitsoft's T-SQL Analyzer and I get the following:


SA0028 : [Deprecated]Function call can be extracted from the WHERE clause to avoid unnecessary table scan.


I'm not sure why I got that error.

Thanks.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)

Group: General Forum Members
Points: 221604 Visits: 42003
Welsh Corgi (1/16/2014)
Lowell (1/16/2014)
dateadd is not deprecated.


I run it through ubitsoft's T-SQL Analyzer and I get the following:


SA0028 : [Deprecated]Function call can be extracted from the WHERE clause to avoid unnecessary table scan.


I'm not sure why I got that error.

Thanks.


Must be a bug with ubitsoft's reporting because, I agree, DATEADD is not deprecated.

Removal of functions wrapped around columns in the WHERE clause is, however, a great idea.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28006 Visits: 4895
I removed the function from the WHERE and replaced it with a local variable:


AND CD_DW_INSERT_DATE > @Date



I got another problem on a JOIN.


Found filtering columns wrapped inside User-Defined Function call.




AND PTD.Ptd_trans_process_date = CypressStaging.dbo.Fncconvertas400date(ExtCov.Last_change_date)




The function dbo.Fncconvertas400date converts AS400 Date format to SQL Server Date.

I do not know if and what I could do for this?

Thanks again.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search