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.
| Author |
Topic |
|
jassie
Constraint Violating Yak Guru
332 Posts |
Posted - 2011-07-26 : 10:26:33
|
| 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? |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2011-07-26 : 11:02:10
|
| 1) Generate Nonclustered indexes on the join conditions. I'm guessing this is as simple as a surrogate Foreign Key -> Primary key mapping? When you create a Foreign Key you don't get an index by default even though you usually want on.Apart from that it's impossible to help you. Tell us about the tables involved, the relationships between them, and sample queries you want to write.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|