When I write report for SQL Reporting Services I put SQL-script inside my report (rdl). When I run this script in SQL Management Studio it takes about 1 second, but report are generated very long time (Sometimes report throws exception about timeout).
Should I write stored procedure and use it in report? Will it be faster?
And one more question – When SQL-script returns a lot of rows, does report get all rows and show only one page, or it takes only one page from SQL-server?
Thanks in advance.
Stored procs vs ad-hoc/dynamic sql:
http://www.codinghorror.com/blog/2005/05/stored-procedures-vs-ad-hoc-sql.html
If data is relatively unchanged between the report being run, you may wish to consider caching:
http://msdn.microsoft.com/en-us/library/ms155927.aspx
I personally favour procs as it makes reuse easier.
You can tap into the RSExecutionlog/(or not!) to see what is going on in terms of how long things are taking to process:
http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/804174a9-0f22-49a7-93f2-be4dbb3c0a4d