Forum guidelines
AuthorQuestion
Sql Server Optimize
Posted on: 26 Jul 2011
I have a question on how to optimize t-sql statement in a sql server 2008 r2 database. In my company one database is being redesigned into 9 other tables. This is due to to the one main table having everyrthing in it the entire database needed.
  I have a stored procedure that i need to change. This stored procedure in the old database only needed to refer to the one table. Now I need to join 9 tables together to obtain the same information.
  **Note this stored procedure is used to supply information into a C#.net 2008 windows application. The application displays information from this stored procedure for users to see. Basically i need all this inforamtion for the new version of the application to work.
Part of the problem is some of the new tables do not contain any inforamtion, since the original may not have contained any information. This, i need to do left outer joins so all rows display.
The new database has one table called 'NEW' that has lots of columns the are separate keys to the new tables.
Thus, can you tell me what to do to optimize this query?



AuthorReply
Re: Sql Server Pptimize
Posted on: 26 Jul 2011  
You can use UNION queries to make the results of multiple queries return as a single resultset.

Re: Sql Server Optimize
Posted on: 26 Jul 2011  
I suggest CTE's - Common Table Expressions.
Mark as Answer, on the posts reply's that helped you !!!.
Re: Sql Server Optimize
Posted on: 26 Jul 2011  
Can you give me an example of CTE's - Common Table Expressions to run join tables and the results work correctly. I would want the results from a left outer join for tables that do not contain the data?
Suthish Nair
  • 0
  • 0
accepted
Re: Sql Server Optimize
Posted on: 27 Jul 2011   Accepted Answer
Using CTE's you can break up the logic data in set of result sets (select queries) and at the end a single SQL Statement will be used to retrieve those records.Do a web search for samples..
Mark as Answer, on the posts reply's that helped you !!!.

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.