Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to clean up this SQL

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-07-22 : 10:37:52
The following SQL is used in a production app in Silverlight. This was developed some of which on-the-fly. There are some aspects that can be changed such as use of temp tables in some cases. http://pastebin.com/3X4qTFMN

I am hearing from a consultant that a temp table may be preferable for the performance.

In general, how would you clean up/ bring to standard practice this SQL?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-07-22 : 11:08:53
Do you mean just to clean up the formatting, or improve the performance? Is it causing performance issues?
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-07-22 : 15:19:17
Mostly performance some fomatting

quote:
Originally posted by robvolk

Do you mean just to clean up the formatting, or improve the performance? Is it causing performance issues?

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-07-22 : 15:39:52
Without some specifics, the only thing I see that raises a flag are the references to the dbo._FnGetBudgetAmount_Spend function, especially in the WHERE clause. If that function selects from any tables or views it will kill performance. I'd suggest getting an execution plan and look for spooling operations and table scans first.
Go to Top of Page
   

- Advertisement -