![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||||
| |||||
|
|
Hello Simon, Thanks for your reply. I guess my next question would be "How do I set up an indexed view?" I look in the Enterprise manager and when I right-click on the view, under "All Tasks" it gives me "Manage Triggers" and "Permissions" but "Manage Indexes" is grayed out. |
|
I downloaded the Production.BAK file to the QA and restored it and ran these views on it. Another point to note is that on the QA server, the QA implementation of the same database, this query runs just fine...max, 35 seconds. But on the Production database, it chokes. I tried doing a DBCC "soft reindexing" on all the tables and then took a SQL trace and ran the Query Optimizer on the Production database on the QA server. Still no luck. |
|
I'd like to learn more about the "Indexed Views" as that sounds like a viable solution. You said the data will be stored in the view? I'm not sure I understand how that works. It's a bit of an "overload" for my Microsoft brain. |
|
While on that subject, would anyone happen to know if I can set up defaults in views? I know how to set it up on the table but I have a scenario where I'd like for different people to see a table through a view and on their "UserID" column, for example, I'd like to default their UserID value on the view. |
|
Thank you again for your help, -Umar Farooq. |
#5
| |||
| |||
|
|
I downloaded the Production.BAK file to the QA and restored it and ran these views on it. Another point to note is that on the QA server, the QA implementation of the same database, this query runs just fine...max, 35 seconds. But on the Production database, it chokes. I tried doing a DBCC "soft reindexing" on all the tables and then took a SQL trace and ran the Query Optimizer on the Production database on the QA server. Still no luck. |
#6
| |||
| |||
|
|
Hello all, Please bear with the long explanation of my scenario. As I'm relatively new to the query world, I like to write my queries using the visual toos such as the "View" option in SQL Server or in MS Access. If I have a complicated query with sub-queries, I create a query (view1) as (for example): select ID,count(ID) as NumberOfUsers from tblContact where Type > 3 GROUP BY ID then create another query (view2) which uses the first view in another select statement: select count(NumberOfUsers) from view1 where NumberOfUsers > 1 What I've noted above is a very simple example but, you get the idea (I hope). My question, however, is regarding a very complex query with cascading/nested views. Scenario: View1 is joining 5 tables View2 is using a join between View1 and 3 more tables View3 is using a join between View2 and 5 more tables View4 is using a join between view3 and 2 more tables When I run VIEW3, it executes within 10 seconds. When I run VIEW4, it takes 4 hours! What I did to get around this problem was this: 1. I renamed View3 to something else - like View3_Test 2. I then exported the new View3_Test into a table called View3 After this modification, when I run View4, it executes in 15 seconds! It seems to me that SQL Server is bundling the joins used in View4...all as 1 view. Is there any way, I can make the execution plan in such a way that it executes (the original) view3 FIRST and then proceeds to execute the rest of the joins in View4? This would be extremely helpful for me because in the interim (sp?), I will have to schedule a DTS package to export the View3_Test to the table called View3 first...upon completion, run the rest of the report. That's just cheating. I'd like to be able to provide a better solution to my employer. Any help will be much appreciated. Thank you in advance for your expert advice, -Umar Farooq. |
#7
| |||
| |||
|
|
I wish there was a way by which I could tell the query to treat the steps I want as a self-contained query and not to combine the execution plan with the other queries in the view. |
|
By default, I mean for inserts. On a table, if I wanted to enter a default date, for example, I'd just do a "getdate()" function on the default property of the date field and it will insert a date in the field by default. I'd like a view to to insert a default value in a column just like the table default. For example: |
|
The problem is that the scenario I've listed above is only for Select views and not for update views. I know I can accomplish this task with a stored procedure which will accept values and hard-code the information into the table but I wanted to do that via a view if possible. |
![]() |
| Thread Tools | |
| Display Modes | |
| |