Sunday, March 11, 2012
2601 Error When Creating or Altering a SPROC SS2005
procedure (or view) in SS2005: "Error: 2601, Severity: 14, State: 1"
To duplicate create a table (table1) start profiler, add errors and
warnings, start the trace, create the proc below
create procedure test
As
select * from table1
select * from table1
go
The number of exceptions you see in the profiler trace is the same as the
number of columns on table1. Is this some kind of database engine problem
where the engine is trying to insert/update sys.sql_dependencies?I could not reproduce this, whether or not the table exists. All I get is a
couple of error 208
(object doesn't exist).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<hpux9@.nospam.nospam> wrote in message news:D1E3C6C5-C624-41C1-A328-86357444DE45@.microsoft.c
om...
>I get the following error(in profiler) when creating or altering a stored
> procedure (or view) in SS2005: "Error: 2601, Severity: 14, State: 1"
> To duplicate create a table (table1) start profiler, add errors and
> warnings, start the trace, create the proc below
> create procedure test
> As
> select * from table1
> select * from table1
> go
> The number of exceptions you see in the profiler trace is the same as the
> number of columns on table1. Is this some kind of database engine problem
> where the engine is trying to insert/update sys.sql_dependencies?
>|||Tibor,
Thanks for the reply. I went back and tested this and it happens in my
production version:
9.00.1399.06 RTM Enterprise Edition (64-bit)
But it does not happen in my development version:
9.00.2047.00 SP1 Developer Edition
Fixed in SP1, or x86 vs x64 bug? I'll try to get the PRD upgraded to SP1
and see if it goes away.
Thanks
"Tibor Karaszi" wrote:
> I could not reproduce this, whether or not the table exists. All I get is
a couple of error 208
> (object doesn't exist).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <hpux9@.nospam.nospam> wrote in message news:D1E3C6C5-C624-41C1-A328-863574
44DE45@.microsoft.com...
>
>|||Upgraded to:
9.00.2047.00 SP1 Enterprise Edition (64-bit)
Still has the same issue. Can anyone else duplicate this issue?
Thanks
"hpux9@.nospam.nospam" wrote:
[vbcol=seagreen]
> Tibor,
> Thanks for the reply. I went back and tested this and it happens in my
> production version:
> 9.00.1399.06 RTM Enterprise Edition (64-bit)
> But it does not happen in my development version:
> 9.00.2047.00 SP1 Developer Edition
> Fixed in SP1, or x86 vs x64 bug? I'll try to get the PRD upgraded to SP1
> and see if it goes away.
> Thanks
> "Tibor Karaszi" wrote:
>
2601 Error When Creating or Altering a SPROC SS2005
procedure (or view) in SS2005: "Error: 2601, Severity: 14, State: 1"
To duplicate create a table (table1) start profiler, add errors and
warnings, start the trace, create the proc below
create procedure test
As
select * from table1
select * from table1
go
The number of exceptions you see in the profiler trace is the same as the
number of columns on table1. Is this some kind of database engine problem
where the engine is trying to insert/update sys.sql_dependencies?I could not reproduce this, whether or not the table exists. All I get is a couple of error 208
(object doesn't exist).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<hpux9@.nospam.nospam> wrote in message news:D1E3C6C5-C624-41C1-A328-86357444DE45@.microsoft.com...
>I get the following error(in profiler) when creating or altering a stored
> procedure (or view) in SS2005: "Error: 2601, Severity: 14, State: 1"
> To duplicate create a table (table1) start profiler, add errors and
> warnings, start the trace, create the proc below
> create procedure test
> As
> select * from table1
> select * from table1
> go
> The number of exceptions you see in the profiler trace is the same as the
> number of columns on table1. Is this some kind of database engine problem
> where the engine is trying to insert/update sys.sql_dependencies?
>|||Tibor,
Thanks for the reply. I went back and tested this and it happens in my
production version:
9.00.1399.06 RTM Enterprise Edition (64-bit)
But it does not happen in my development version:
9.00.2047.00 SP1 Developer Edition
Fixed in SP1, or x86 vs x64 bug? I'll try to get the PRD upgraded to SP1
and see if it goes away.
Thanks
"Tibor Karaszi" wrote:
> I could not reproduce this, whether or not the table exists. All I get is a couple of error 208
> (object doesn't exist).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <hpux9@.nospam.nospam> wrote in message news:D1E3C6C5-C624-41C1-A328-86357444DE45@.microsoft.com...
> >I get the following error(in profiler) when creating or altering a stored
> > procedure (or view) in SS2005: "Error: 2601, Severity: 14, State: 1"
> >
> > To duplicate create a table (table1) start profiler, add errors and
> > warnings, start the trace, create the proc below
> >
> > create procedure test
> > As
> > select * from table1
> > select * from table1
> > go
> >
> > The number of exceptions you see in the profiler trace is the same as the
> > number of columns on table1. Is this some kind of database engine problem
> > where the engine is trying to insert/update sys.sql_dependencies?
> >
> >
>
>|||Upgraded to:
9.00.2047.00 SP1 Enterprise Edition (64-bit)
Still has the same issue. Can anyone else duplicate this issue?
Thanks
"hpux9@.nospam.nospam" wrote:
> Tibor,
> Thanks for the reply. I went back and tested this and it happens in my
> production version:
> 9.00.1399.06 RTM Enterprise Edition (64-bit)
> But it does not happen in my development version:
> 9.00.2047.00 SP1 Developer Edition
> Fixed in SP1, or x86 vs x64 bug? I'll try to get the PRD upgraded to SP1
> and see if it goes away.
> Thanks
> "Tibor Karaszi" wrote:
> > I could not reproduce this, whether or not the table exists. All I get is a couple of error 208
> > (object doesn't exist).
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > <hpux9@.nospam.nospam> wrote in message news:D1E3C6C5-C624-41C1-A328-86357444DE45@.microsoft.com...
> > >I get the following error(in profiler) when creating or altering a stored
> > > procedure (or view) in SS2005: "Error: 2601, Severity: 14, State: 1"
> > >
> > > To duplicate create a table (table1) start profiler, add errors and
> > > warnings, start the trace, create the proc below
> > >
> > > create procedure test
> > > As
> > > select * from table1
> > > select * from table1
> > > go
> > >
> > > The number of exceptions you see in the profiler trace is the same as the
> > > number of columns on table1. Is this some kind of database engine problem
> > > where the engine is trying to insert/update sys.sql_dependencies?
> > >
> > >
> >
> >
> >
Thursday, March 8, 2012
24000 Invalid cursor state. Prepared Statement
I am not using / importing any dlls.
I connect+allocs handels , then use SQLPrepare(StmtHandle, SQLStmt,SQL_NTS); to generate a guery.
I have written bind parameters and sqlexecute +sqlFetch in a loop and loop gets executed till ESC key is pressed.
First time when I bind paramaters using SQLBindParameter it works perfect.
When loop gets executed secondtime onwards, it gives an error.
SQLState: 24000 [ODBC Client Interface]Invalid cursor state.
If I open connection, handles, and prepared starement in same loop, THEN it gives correct record without 24000 error.
I want the advantage of prepared staement. So I do not want to close and open connection and prepare statement every time.
Have I missed any step?
Where & when I should code the cursor type? Any specific libraries I need to link?
Thanksyes you missed something. see brett's sticky at the top of the page.|||I traced the solution.
I thought that the mistake is in declaring scrollable cursors.
So I explained precisouly the problem in 7-8 lines.
Reading 50-60 lines with altogether different coding standards is difficult.
Its not coding problem but associated with scrollable cursor options.
So I did not include the code.
MSDN examples does not show such required step as the scope of example code gets over before such situation is reached!!.
2006-09-13 15:24:18.07 Logon Error: 18456, Severity: 14, State: 16.
well this is a strange one.
i have a sql 2005 server express running on a pc. it has an xp embedded database on it.
i can connect to it from one pc using component database manager.
however, if i try this from another pc it fails with the following code
2006-09-13 15:24:18.07 Logon Error: 18456, Severity: 14, State: 16.
2006-09-13 15:24:18.07 Logon Login failed for user 'HOSTNAME\Guest'. [CLIENT: XX.XX.XX.XX]
.
i have simple file sharing turned of on the remote pc that fails to connect.
what is my problem.
YOu will have to disable simple filesharing at the WIndows box, because the user will be otherwise authenticated by the Guest user.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
|||This has been done on both db client pcs the one that failed and the one that succeded.
explorer->tools->folder options->view->Use simple file sharing checkbox.
i unchecked this checkbox.
i then rebooted the client pc.
thanks,
|||Logon Error: 18456, Severity: 14, State: 11.
I'm using Sql server 2005 on vista.....
please give me some hints to solve the problem, thanks a lot!
Min
2006-09-13 15:24:18.07 Logon Error: 18456, Severity: 14, State: 16.
well this is a strange one.
i have a sql 2005 server express running on a pc. it has an xp embedded database on it.
i can connect to it from one pc using component database manager.
however, if i try this from another pc it fails with the following code
2006-09-13 15:24:18.07 Logon Error: 18456, Severity: 14, State: 16.
2006-09-13 15:24:18.07 Logon Login failed for user 'HOSTNAME\Guest'. [CLIENT: XX.XX.XX.XX]
.
i have simple file sharing turned of on the remote pc that fails to connect.
what is my problem.
YOu will have to disable simple filesharing at the WIndows box, because the user will be otherwise authenticated by the Guest user.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
|||This has been done on both db client pcs the one that failed and the one that succeded.
explorer->tools->folder options->view->Use simple file sharing checkbox.
i unchecked this checkbox.
i then rebooted the client pc.
thanks,
|||Logon Error: 18456, Severity: 14, State: 11.
I'm using Sql server 2005 on vista.....
please give me some hints to solve the problem, thanks a lot!
Min
Tuesday, March 6, 2012
2005 vs 2008 NOEXPAND hint behavior
With SQL 2005, using the NOEXPAND hint can result in an error:
Msg 8171, Level 16, State 2, Line 1
Hint 'noexpand' on object 'dbo.ervStats' is invalid.
I haven't tried it with 2008 yet but I expect the same behavior. That behavior can cause problems and I would like to understand the logic behind it. I would expect a Warning to be raised, not an error.
Scenario:
OLTP application using one or more indexed view to speed up some functionalities. This can happen as some db are OLTP but also used for real time reporting that can't be done on a mirror. At some point you may find out 1 indexed view is the cause of excessive locking for 1 specific site, so you remove the index....but must now recompile and redeploy the application to hundreds of desktops to remove that 8171 error message.
If a warning was issued instead of an error, the problem would not occur. Nothing is changed at the logical level and the query would run as expected is the hint was ignored.
There is possibly a very good reason to raise an error instead of a warning, but I can't see it right now. Before I create a feature request on Connect can somebody shed some light on that behavior? (I might change my mind once I understand the logic:-) )
PS: I KNOW indexed views are not meat for OLTP scenarios, but there are edge cases where they do help when designed properly. Sometimes business scenarios change and they must be changed or dropped.
thanks
L
Hi Lakusha - I'm not sure of the direct answer to your question, but as another option vs. recompiling and redeploying your application, have you looked at the possibility of using a plan guide for addressing the issue?
|||
Hi Chad,
No, I haven't looked at plan guides for this. Perhaps I am wrong, but I feel plan guides can't help much in our context. We have hundreds of servers at hundreds of locations (ISV context). I can manage plan guides easily but customers support teams won't. Even something as trivial as dropping an index on a view can prove too much because their schema becomes non standard and they must remember to drop it again after each major upgrades (and sometimes they won't and this will become a support call). Support will check immediately if they upgraded recently and forgot to run the drop index script but plan guides are another matter.
A plan guide will also lock you up. In a complex query I might want to use a NOEXPAND on a materialized view (especially when the Enterprise query optimizer sometimes can't be trusted to choose the view but also because some customers use the Enterprise versions while others use Standard...so the lowest common denominator wins) but I certainly don't want to force the plan on the entire query because it will certainly be a good plan for some customers but not for others.
I also think that discarding a hint is certainly worth a warning but not an error since it does not change anything from a logical stand point. The exact behavior could even be controlled at the db level, or even better, at the hint level.
Most of all, I would like to understand why they choose to raise an error and not a warning. In the end it is best to understand why things work a certain way.
PS: I know MS Research has done a lot of work to support outer joins and stacked indexed views but I haven't seen anything new advertized for indexed views in SQL2008...
thanks
L
|||
Hi Lakusha. Let me try to address points mentioned in this thread one by one.
The behavior of noexpand hint is same as any other hint and, as far as I know, except consistency with other hints there are no other fundamental reasons why it is an error instead of a warning. You definitely can propose this via Connect.
Plan guides will not really solve this problem (with one exception, see my next bullet) since noexpand hint is not a query hint.
You can make a plan guide with USE PLAN providing plan which has indexed view in it and this will force using indexed view same way as noexpand hint. But ... you will be pinning whole plan not allowing for potentially better alternatives as circumstances change, and in SQL Server 2005 it still will generate an error if index is not present on the view. In CTP5 we are planning to have plan guides functionality which will not error out in such case but rather generate plan as if no plan guide was present.
The only workaround I know about is to wrap your query in an SP with following logic:
if <Index is present on the view>
then <run query with noexpand hint in it>
else <run same query without noexpand hint>
There is an added inconvenience of having to wrap it into SP, but it will let you avoid redeployments you mention.
Thanks Alex.
I might make a suggestion about this on Connect then. As for plan guides, I am aware of the drawbacks. Using a SP is indeed a good suggestion. I did not consider it because, for internal reasons, we have chosen to never use them. It is the old adhoc vs SP debate again and in our case ad hoc queries won (we use a DAL that works quite a bit like LINQ).
Thanks
|||Thanks for the post. It's very helpful.
Do you mind providing some more insight regarding the 3rd bullet? I have an ad-hoc query submitted from Business Objects. When I copy the query from Profiler and add a "noexpand", the query runs lightening fast. Without the "noexpand", the query is tremendously inefficient.
So, I then ran the query (with the noexpand) and captured the showplan XML and stuffed the showplan results into the use plan option. Next, when I run the query (with the noexpand and the use plan), it runs great.
Then, when I remove the "noexpand" from the query (but not the use plan), the following error is issued:
Msg 8698, Level 16, State 0, Line 2
Query processor could not produce query plan because USE PLAN hint contains plan that could not be verified to be legal for query. Remove or replace USE PLAN hint. For best likelihood of successful plan forcing, verify that the plan provided in the USE PLAN hint is one generated automatically by SQL Server for the same query.
The reason I removed "noexpand" from the query is because Business Objects does not submit the query with noexpand. I suspect that the reason the error was issued is because the query expanded the view and the plan did not.
In all cases, the query referenced the indexed view. We are running the Enterprise version.
So, how can noexpand be implemented when my company is not the author of the code?
- Is there a machine or database level configuration that could be set?
- How can a noexpand appear in the plan but not in the query without getting the error message above?
- Other?
Any insight you provide will be greatly appreciated!
|||(DaveIII@.discussions.microsoft.com) writes: > Then, when I remove the "noexpand" from the query (but not the use > plan), the following error is issued: > > > > Msg 8698, Level 16, State 0, Line 2 > > Query processor could not produce query plan because USE PLAN hint > contains plan that could not be verified to be legal for query. Remove > or replace USE PLAN hint. For best likelihood of successful plan > forcing, verify that the plan provided in the USE PLAN hint is one > generated automatically by SQL Server for the same query. I guess this is because that in order to validate that your plan is valid, the optimizer keeps generating plans, until it has generated yours. But when the query has NOEXPAND, the optimizer never sees the indexed view; it sees the expanded query, and then will have to try view substitution to come back to the view. And since view substitution is an expensive operation, it does not try everything. Clearly, this is not a very pleasant situation. If nothing else, it's not a very intuitive behaviour. I have not checked Books Online, to see if this restriction is documented. I think you should submit this issue on Connect, but check Books Online first, as I think you should have a different angle depending on whether it's documented or not. If it's not documented, just submit it as a bug. If it's documented, you are better off making this as a suggestion, I think. Of course, in either case, the devs would appreciate if you can supply a repro. -- Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
2005 vs 2008 NOEXPAND hint behavior
With SQL 2005, using the NOEXPAND hint can result in an error:
Msg 8171, Level 16, State 2, Line 1
Hint 'noexpand' on object 'dbo.ervStats' is invalid.
I haven't tried it with 2008 yet but I expect the same behavior. That behavior can cause problems and I would like to understand the logic behind it. I would expect a Warning to be raised, not an error.
Scenario:
OLTP application using one or more indexed view to speed up some functionalities. This can happen as some db are OLTP but also used for real time reporting that can't be done on a mirror. At some point you may find out 1 indexed view is the cause of excessive locking for 1 specific site, so you remove the index....but must now recompile and redeploy the application to hundreds of desktops to remove that 8171 error message.
If a warning was issued instead of an error, the problem would not occur. Nothing is changed at the logical level and the query would run as expected is the hint was ignored.
There is possibly a very good reason to raise an error instead of a warning, but I can't see it right now. Before I create a feature request on Connect can somebody shed some light on that behavior? (I might change my mind once I understand the logic:-) )
PS: I KNOW indexed views are not meat for OLTP scenarios, but there are edge cases where they do help when designed properly. Sometimes business scenarios change and they must be changed or dropped.
thanks
L
Hi Lakusha - I'm not sure of the direct answer to your question, but as another option vs. recompiling and redeploying your application, have you looked at the possibility of using a plan guide for addressing the issue?
|||Hi Chad,
No, I haven't looked at plan guides for this. Perhaps I am wrong, but I feel plan guides can't help much in our context. We have hundreds of servers at hundreds of locations (ISV context). I can manage plan guides easily but customers support teams won't. Even something as trivial as dropping an index on a view can prove too much because their schema becomes non standard and they must remember to drop it again after each major upgrades (and sometimes they won't and this will become a support call). Support will check immediately if they upgraded recently and forgot to run the drop index script but plan guides are another matter.
A plan guide will also lock you up. In a complex query I might want to use a NOEXPAND on a materialized view (especially when the Enterprise query optimizer sometimes can't be trusted to choose the view but also because some customers use the Enterprise versions while others use Standard...so the lowest common denominator wins) but I certainly don't want to force the plan on the entire query because it will certainly be a good plan for some customers but not for others.
I also think that discarding a hint is certainly worth a warning but not an error since it does not change anything from a logical stand point. The exact behavior could even be controlled at the db level, or even better, at the hint level.
Most of all, I would like to understand why they choose to raise an error and not a warning. In the end it is best to understand why things work a certain way.
PS: I know MS Research has done a lot of work to support outer joins and stacked indexed views but I haven't seen anything new advertized for indexed views in SQL2008...
thanks
L
|||Hi Lakusha. Let me try to address points mentioned in this thread one by one.
The behavior of noexpand hint is same as any other hint and, as far as I know, except consistency with other hints there are no other fundamental reasons why it is an error instead of a warning. You definitely can propose this via Connect.
Plan guides will not really solve this problem (with one exception, see my next bullet) since noexpand hint is not a query hint.
You can make a plan guide with USE PLAN providing plan which has indexed view in it and this will force using indexed view same way as noexpand hint. But ... you will be pinning whole plan not allowing for potentially better alternatives as circumstances change, and in SQL Server 2005 it still will generate an error if index is not present on the view. In CTP5 we are planning to have plan guides functionality which will not error out in such case but rather generate plan as if no plan guide was present.
The only workaround I know about is to wrap your query in an SP with following logic:
if <Index is present on the view>
then <run query with noexpand hint in it>
else <run same query without noexpand hint>
There is an added inconvenience of having to wrap it into SP, but it will let you avoid redeployments you mention.
Thanks Alex.
I might make a suggestion about this on Connect then. As for plan guides, I am aware of the drawbacks. Using a SP is indeed a good suggestion. I did not consider it because, for internal reasons, we have chosen to never use them. It is the old adhoc vs SP debate again and in our case ad hoc queries won (we use a DAL that works quite a bit like LINQ).
Thanks
|||Thanks for the post. It's very helpful.
Do you mind providing some more insight regarding the 3rd bullet? I have an ad-hoc query submitted from Business Objects. When I copy the query from Profiler and add a "noexpand", the query runs lightening fast. Without the "noexpand", the query is tremendously inefficient.
So, I then ran the query (with the noexpand) and captured the showplan XML and stuffed the showplan results into the use plan option. Next, when I run the query (with the noexpand and the use plan), it runs great.
Then, when I remove the "noexpand" from the query (but not the use plan), the following error is issued:
Msg 8698, Level 16, State 0, Line 2
Query processor could not produce query plan because USE PLAN hint contains plan that could not be verified to be legal for query. Remove or replace USE PLAN hint. For best likelihood of successful plan forcing, verify that the plan provided in the USE PLAN hint is one generated automatically by SQL Server for the same query.
The reason I removed "noexpand" from the query is because Business Objects does not submit the query with noexpand. I suspect that the reason the error was issued is because the query expanded the view and the plan did not.
In all cases, the query referenced the indexed view. We are running the Enterprise version.
So, how can noexpand be implemented when my company is not the author of the code?
- Is there a machine or database level configuration that could be set?
- How can a noexpand appear in the plan but not in the query without getting the error message above?
- Other?
Any insight you provide will be greatly appreciated!
|||(DaveIII@.discussions.microsoft.com) writes: > Then, when I remove the "noexpand" from the query (but not the use > plan), the following error is issued: > > > > Msg 8698, Level 16, State 0, Line 2 > > Query processor could not produce query plan because USE PLAN hint > contains plan that could not be verified to be legal for query. Remove > or replace USE PLAN hint. For best likelihood of successful plan > forcing, verify that the plan provided in the USE PLAN hint is one > generated automatically by SQL Server for the same query. I guess this is because that in order to validate that your plan is valid, the optimizer keeps generating plans, until it has generated yours. But when the query has NOEXPAND, the optimizer never sees the indexed view; it sees the expanded query, and then will have to try view substitution to come back to the view. And since view substitution is an expensive operation, it does not try everything. Clearly, this is not a very pleasant situation. If nothing else, it's not a very intuitive behaviour. I have not checked Books Online, to see if this restriction is documented. I think you should submit this issue on Connect, but check Books Online first, as I think you should have a different angle depending on whether it's documented or not. If it's not documented, just submit it as a bug. If it's documented, you are better off making this as a suggestion, I think. Of course, in either case, the devs would appreciate if you can supply a repro. -- Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
2005 vs 2008 NOEXPAND hint behavior
With SQL 2005, using the NOEXPAND hint can result in an error:
Msg 8171, Level 16, State 2, Line 1
Hint 'noexpand' on object 'dbo.ervStats' is invalid.
I haven't tried it with 2008 yet but I expect the same behavior. That behavior can cause problems and I would like to understand the logic behind it. I would expect a Warning to be raised, not an error.
Scenario:
OLTP application using one or more indexed view to speed up some functionalities. This can happen as some db are OLTP but also used for real time reporting that can't be done on a mirror. At some point you may find out 1 indexed view is the cause of excessive locking for 1 specific site, so you remove the index....but must now recompile and redeploy the application to hundreds of desktops to remove that 8171 error message.
If a warning was issued instead of an error, the problem would not occur. Nothing is changed at the logical level and the query would run as expected is the hint was ignored.
There is possibly a very good reason to raise an error instead of a warning, but I can't see it right now. Before I create a feature request on Connect can somebody shed some light on that behavior? (I might change my mind once I understand the logic:-) )
PS: I KNOW indexed views are not meat for OLTP scenarios, but there are edge cases where they do help when designed properly. Sometimes business scenarios change and they must be changed or dropped.
thanks
L
Hi Lakusha - I'm not sure of the direct answer to your question, but as another option vs. recompiling and redeploying your application, have you looked at the possibility of using a plan guide for addressing the issue?
|||Hi Chad,
No, I haven't looked at plan guides for this. Perhaps I am wrong, but I feel plan guides can't help much in our context. We have hundreds of servers at hundreds of locations (ISV context). I can manage plan guides easily but customers support teams won't. Even something as trivial as dropping an index on a view can prove too much because their schema becomes non standard and they must remember to drop it again after each major upgrades (and sometimes they won't and this will become a support call). Support will check immediately if they upgraded recently and forgot to run the drop index script but plan guides are another matter.
A plan guide will also lock you up. In a complex query I might want to use a NOEXPAND on a materialized view (especially when the Enterprise query optimizer sometimes can't be trusted to choose the view but also because some customers use the Enterprise versions while others use Standard...so the lowest common denominator wins) but I certainly don't want to force the plan on the entire query because it will certainly be a good plan for some customers but not for others.
I also think that discarding a hint is certainly worth a warning but not an error since it does not change anything from a logical stand point. The exact behavior could even be controlled at the db level, or even better, at the hint level.
Most of all, I would like to understand why they choose to raise an error and not a warning. In the end it is best to understand why things work a certain way.
PS: I know MS Research has done a lot of work to support outer joins and stacked indexed views but I haven't seen anything new advertized for indexed views in SQL2008...
thanks
L
|||Hi Lakusha. Let me try to address points mentioned in this thread one by one.
The behavior of noexpand hint is same as any other hint and, as far as I know, except consistency with other hints there are no other fundamental reasons why it is an error instead of a warning. You definitely can propose this via Connect.
Plan guides will not really solve this problem (with one exception, see my next bullet) since noexpand hint is not a query hint.
You can make a plan guide with USE PLAN providing plan which has indexed view in it and this will force using indexed view same way as noexpand hint. But ... you will be pinning whole plan not allowing for potentially better alternatives as circumstances change, and in SQL Server 2005 it still will generate an error if index is not present on the view. In CTP5 we are planning to have plan guides functionality which will not error out in such case but rather generate plan as if no plan guide was present.
The only workaround I know about is to wrap your query in an SP with following logic:
if <Index is present on the view>
then <run query with noexpand hint in it>
else <run same query without noexpand hint>
There is an added inconvenience of having to wrap it into SP, but it will let you avoid redeployments you mention.
Thanks Alex.
I might make a suggestion about this on Connect then. As for plan guides, I am aware of the drawbacks. Using a SP is indeed a good suggestion. I did not consider it because, for internal reasons, we have chosen to never use them. It is the old adhoc vs SP debate again and in our case ad hoc queries won (we use a DAL that works quite a bit like LINQ).
Thanks
|||Thanks for the post. It's very helpful.
Do you mind providing some more insight regarding the 3rd bullet? I have an ad-hoc query submitted from Business Objects. When I copy the query from Profiler and add a "noexpand", the query runs lightening fast. Without the "noexpand", the query is tremendously inefficient.
So, I then ran the query (with the noexpand) and captured the showplan XML and stuffed the showplan results into the use plan option. Next, when I run the query (with the noexpand and the use plan), it runs great.
Then, when I remove the "noexpand" from the query (but not the use plan), the following error is issued:
Msg 8698, Level 16, State 0, Line 2
Query processor could not produce query plan because USE PLAN hint contains plan that could not be verified to be legal for query. Remove or replace USE PLAN hint. For best likelihood of successful plan forcing, verify that the plan provided in the USE PLAN hint is one generated automatically by SQL Server for the same query.
The reason I removed "noexpand" from the query is because Business Objects does not submit the query with noexpand. I suspect that the reason the error was issued is because the query expanded the view and the plan did not.
In all cases, the query referenced the indexed view. We are running the Enterprise version.
So, how can noexpand be implemented when my company is not the author of the code?
- Is there a machine or database level configuration that could be set?
- How can a noexpand appear in the plan but not in the query without getting the error message above?
- Other?
Any insight you provide will be greatly appreciated!
|||(DaveIII@.discussions.microsoft.com) writes: > Then, when I remove the "noexpand" from the query (but not the use > plan), the following error is issued: > > > > Msg 8698, Level 16, State 0, Line 2 > > Query processor could not produce query plan because USE PLAN hint > contains plan that could not be verified to be legal for query. Remove > or replace USE PLAN hint. For best likelihood of successful plan > forcing, verify that the plan provided in the USE PLAN hint is one > generated automatically by SQL Server for the same query. I guess this is because that in order to validate that your plan is valid, the optimizer keeps generating plans, until it has generated yours. But when the query has NOEXPAND, the optimizer never sees the indexed view; it sees the expanded query, and then will have to try view substitution to come back to the view. And since view substitution is an expensive operation, it does not try everything. Clearly, this is not a very pleasant situation. If nothing else, it's not a very intuitive behaviour. I have not checked Books Online, to see if this restriction is documented. I think you should submit this issue on Connect, but check Books Online first, as I think you should have a different angle depending on whether it's documented or not. If it's not documented, just submit it as a bug. If it's documented, you are better off making this as a suggestion, I think. Of course, in either case, the devs would appreciate if you can supply a repro. -- Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Saturday, February 11, 2012
2005 client tools
Are just the client tools freely downloadable and installable, or is a
license required, or are the client tools not even available outside of a
full product install (even if it's just express)?
(and if you happen to have the link handy ... thanks for posting it!)
Whatever has to be installed, will it work with Vista?
Does it have to be Vista Pro? (not sure which we have)
If that requires SQL Server 2005 SP2 to install/run on Vista, will that be
OK connecting to SP1 servers?
Sorry to ask such dumb questions, but some googling of the site and
newsgroups has not sufficiently enlightened me.
Thanks.
Josh
See in-line:
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"JRStern" <JRStern@.discussions.microsoft.com> wrote in message
news:499D51EE-02B3-44D1-AD00-2FFBBBEE4243@.microsoft.com...
> Couple of questions about the current state of things regarding client
> tools.
> Are just the client tools freely downloadable and installable, or is a
> license required, or are the client tools not even available outside of a
> full product install (even if it's just express)?
The full client tools come with a fully licensed product and can not be
purchased seperately. If this is for devel purposes I would suggest buying
the developer edition which is less than $100 and you get it all. The
Express version is free but is only for Express edition of SQL Server.
> (and if you happen to have the link handy ... thanks for posting it!)
> Whatever has to be installed, will it work with Vista?
SQL2005 SP2 works with Vista.
> Does it have to be Vista Pro? (not sure which we have)
Developer edition works with all editions of vista.
> If that requires SQL Server 2005 SP2 to install/run on Vista, will that be
> OK connecting to SP1 servers?
Yes
> Sorry to ask such dumb questions, but some googling of the site and
> newsgroups has not sufficiently enlightened me.
> Thanks.
> Josh
>
|||Andrew, thanks very much.
This is in a corporate dev group, however the workstation (laptop) is owned
by contractor. We certainly have many licensed copies of SQLServer, and this
is for dev, so are we allowed to install client tools on ("visiting") laptop?
Probably need to have contractor get own (and I need one for home, or maybe
I should now wait until March and skip to 2008!)
Thanks again,
Josh
"Andrew J. Kelly" wrote:
> See in-line:
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "JRStern" <JRStern@.discussions.microsoft.com> wrote in message
> news:499D51EE-02B3-44D1-AD00-2FFBBBEE4243@.microsoft.com...
> The full client tools come with a fully licensed product and can not be
> purchased seperately. If this is for devel purposes I would suggest buying
> the developer edition which is less than $100 and you get it all. The
> Express version is free but is only for Express edition of SQL Server.
>
> SQL2005 SP2 works with Vista.
>
> Developer edition works with all editions of vista.
>
> Yes
>
>
|||You can wait until March but you won't have 2008
actually ship until the end of 2nd quarter 2008 which is end of June. The
launch will be in Feb but SQL Server 2008 will not be ready for shipping at
that time.
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"JRStern" <JRStern@.discussions.microsoft.com> wrote in message
news:E6FC84B2-D6AC-401D-BF90-DCC941D1DD33@.microsoft.com...[vbcol=seagreen]
> Andrew, thanks very much.
> This is in a corporate dev group, however the workstation (laptop) is
> owned
> by contractor. We certainly have many licensed copies of SQLServer, and
> this
> is for dev, so are we allowed to install client tools on ("visiting")
> laptop?
>
> Probably need to have contractor get own (and I need one for home, or
> maybe
> I should now wait until March and skip to 2008!)
> Thanks again,
> Josh
>
> "Andrew J. Kelly" wrote:
|||Ohhh. Just as well, probably need to upgrade the ol' workstation anyway.
Josh
"Andrew J. Kelly" wrote:
> You can wait until March but you won't have 2008
> actually ship until the end of 2nd quarter 2008 which is end of June. The
> launch will be in Feb but SQL Server 2008 will not be ready for shipping at
> that time.
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "JRStern" <JRStern@.discussions.microsoft.com> wrote in message
> news:E6FC84B2-D6AC-401D-BF90-DCC941D1DD33@.microsoft.com...
>
2005 client tools
.
Are just the client tools freely downloadable and installable, or is a
license required, or are the client tools not even available outside of a
full product install (even if it's just express)?
(and if you happen to have the link handy ... thanks for posting it!)
Whatever has to be installed, will it work with Vista?
Does it have to be Vista Pro? (not sure which we have)
If that requires SQL Server 2005 SP2 to install/run on Vista, will that be
OK connecting to SP1 servers?
Sorry to ask such dumb questions, but some googling of the site and
newsgroups has not sufficiently enlightened me.
Thanks.
JoshSee in-line:
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"JRStern" <JRStern@.discussions.microsoft.com> wrote in message
news:499D51EE-02B3-44D1-AD00-2FFBBBEE4243@.microsoft.com...
> Couple of questions about the current state of things regarding client
> tools.
> Are just the client tools freely downloadable and installable, or is a
> license required, or are the client tools not even available outside of a
> full product install (even if it's just express)?
The full client tools come with a fully licensed product and can not be
purchased seperately. If this is for devel purposes I would suggest buying
the developer edition which is less than $100 and you get it all. The
Express version is free but is only for Express edition of SQL Server.
> (and if you happen to have the link handy ... thanks for posting it!)
> Whatever has to be installed, will it work with Vista?
SQL2005 SP2 works with Vista.
> Does it have to be Vista Pro? (not sure which we have)
Developer edition works with all editions of vista.
> If that requires SQL Server 2005 SP2 to install/run on Vista, will that be
> OK connecting to SP1 servers?
Yes
> Sorry to ask such dumb questions, but some googling of the site and
> newsgroups has not sufficiently enlightened me.
> Thanks.
> Josh
>|||Andrew, thanks very much.
This is in a corporate dev group, however the workstation (laptop) is owned
by contractor. We certainly have many licensed copies of SQLServer, and thi
s
is for dev, so are we allowed to install client tools on ("visiting") laptop
?
Probably need to have contractor get own (and I need one for home, or maybe
I should now wait until March and skip to 2008!)
Thanks again,
Josh
"Andrew J. Kelly" wrote:
> See in-line:
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "JRStern" <JRStern@.discussions.microsoft.com> wrote in message
> news:499D51EE-02B3-44D1-AD00-2FFBBBEE4243@.microsoft.com...
> The full client tools come with a fully licensed product and can not be
> purchased seperately. If this is for devel purposes I would suggest buying
> the developer edition which is less than $100 and you get it all. The
> Express version is free but is only for Express edition of SQL Server.
>
>
> SQL2005 SP2 works with Vista.
>
> Developer edition works with all editions of vista.
>
> Yes
>
>|||You can wait until March but you won't have 2008
actually ship until the end of 2nd quarter 2008 which is end of June. The
launch will be in Feb but SQL Server 2008 will not be ready for shipping at
that time.
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"JRStern" <JRStern@.discussions.microsoft.com> wrote in message
news:E6FC84B2-D6AC-401D-BF90-DCC941D1DD33@.microsoft.com...[vbcol=seagreen]
> Andrew, thanks very much.
> This is in a corporate dev group, however the workstation (laptop) is
> owned
> by contractor. We certainly have many licensed copies of SQLServer, and
> this
> is for dev, so are we allowed to install client tools on ("visiting")
> laptop?
>
> Probably need to have contractor get own (and I need one for home, or
> maybe
> I should now wait until March and skip to 2008!)
> Thanks again,
> Josh
>
> "Andrew J. Kelly" wrote:
>|||Ohhh. Just as well, probably need to upgrade the ol' workstation anyway.
Josh
"Andrew J. Kelly" wrote:
> You can wait until March but you won't have 2008
> actually ship until the end of 2nd quarter 2008 which is end of June. The
> launch will be in Feb but SQL Server 2008 will not be ready for shipping a
t
> that time.
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "JRStern" <JRStern@.discussions.microsoft.com> wrote in message
> news:E6FC84B2-D6AC-401D-BF90-DCC941D1DD33@.microsoft.com...
>
2005 client tools
Are just the client tools freely downloadable and installable, or is a
license required, or are the client tools not even available outside of a
full product install (even if it's just express)?
(and if you happen to have the link handy ... thanks for posting it!)
Whatever has to be installed, will it work with Vista?
Does it have to be Vista Pro? (not sure which we have)
If that requires SQL Server 2005 SP2 to install/run on Vista, will that be
OK connecting to SP1 servers?
Sorry to ask such dumb questions, but some googling of the site and
newsgroups has not sufficiently enlightened me.
Thanks.
JoshSee in-line:
--
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"JRStern" <JRStern@.discussions.microsoft.com> wrote in message
news:499D51EE-02B3-44D1-AD00-2FFBBBEE4243@.microsoft.com...
> Couple of questions about the current state of things regarding client
> tools.
> Are just the client tools freely downloadable and installable, or is a
> license required, or are the client tools not even available outside of a
> full product install (even if it's just express)?
The full client tools come with a fully licensed product and can not be
purchased seperately. If this is for devel purposes I would suggest buying
the developer edition which is less than $100 and you get it all. The
Express version is free but is only for Express edition of SQL Server.
> (and if you happen to have the link handy ... thanks for posting it!)
> Whatever has to be installed, will it work with Vista?
SQL2005 SP2 works with Vista.
> Does it have to be Vista Pro? (not sure which we have)
Developer edition works with all editions of vista.
> If that requires SQL Server 2005 SP2 to install/run on Vista, will that be
> OK connecting to SP1 servers?
Yes
> Sorry to ask such dumb questions, but some googling of the site and
> newsgroups has not sufficiently enlightened me.
> Thanks.
> Josh
>|||Andrew, thanks very much.
This is in a corporate dev group, however the workstation (laptop) is owned
by contractor. We certainly have many licensed copies of SQLServer, and this
is for dev, so are we allowed to install client tools on ("visiting") laptop?
Probably need to have contractor get own (and I need one for home, or maybe
I should now wait until March and skip to 2008!)
Thanks again,
Josh
"Andrew J. Kelly" wrote:
> See in-line:
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "JRStern" <JRStern@.discussions.microsoft.com> wrote in message
> news:499D51EE-02B3-44D1-AD00-2FFBBBEE4243@.microsoft.com...
> > Couple of questions about the current state of things regarding client
> > tools.
> >
> > Are just the client tools freely downloadable and installable, or is a
> > license required, or are the client tools not even available outside of a
> > full product install (even if it's just express)?
> The full client tools come with a fully licensed product and can not be
> purchased seperately. If this is for devel purposes I would suggest buying
> the developer edition which is less than $100 and you get it all. The
> Express version is free but is only for Express edition of SQL Server.
> > (and if you happen to have the link handy ... thanks for posting it!)
> > Whatever has to be installed, will it work with Vista?
> SQL2005 SP2 works with Vista.
> > Does it have to be Vista Pro? (not sure which we have)
> Developer edition works with all editions of vista.
> > If that requires SQL Server 2005 SP2 to install/run on Vista, will that be
> > OK connecting to SP1 servers?
> Yes
> > Sorry to ask such dumb questions, but some googling of the site and
> > newsgroups has not sufficiently enlightened me.
> >
> > Thanks.
> >
> > Josh
> >
>|||You can wait until March but you won't have 2008:). It isn't set to
actually ship until the end of 2nd quarter 2008 which is end of June. The
launch will be in Feb but SQL Server 2008 will not be ready for shipping at
that time.
--
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"JRStern" <JRStern@.discussions.microsoft.com> wrote in message
news:E6FC84B2-D6AC-401D-BF90-DCC941D1DD33@.microsoft.com...
> Andrew, thanks very much.
> This is in a corporate dev group, however the workstation (laptop) is
> owned
> by contractor. We certainly have many licensed copies of SQLServer, and
> this
> is for dev, so are we allowed to install client tools on ("visiting")
> laptop?
>
> Probably need to have contractor get own (and I need one for home, or
> maybe
> I should now wait until March and skip to 2008!)
> Thanks again,
> Josh
>
> "Andrew J. Kelly" wrote:
>> See in-line:
>> --
>> Andrew J. Kelly SQL MVP
>> Solid Quality Mentors
>>
>> "JRStern" <JRStern@.discussions.microsoft.com> wrote in message
>> news:499D51EE-02B3-44D1-AD00-2FFBBBEE4243@.microsoft.com...
>> > Couple of questions about the current state of things regarding client
>> > tools.
>> >
>> > Are just the client tools freely downloadable and installable, or is a
>> > license required, or are the client tools not even available outside of
>> > a
>> > full product install (even if it's just express)?
>> The full client tools come with a fully licensed product and can not be
>> purchased seperately. If this is for devel purposes I would suggest
>> buying
>> the developer edition which is less than $100 and you get it all. The
>> Express version is free but is only for Express edition of SQL Server.
>> > (and if you happen to have the link handy ... thanks for posting it!)
>> > Whatever has to be installed, will it work with Vista?
>> SQL2005 SP2 works with Vista.
>> > Does it have to be Vista Pro? (not sure which we have)
>> Developer edition works with all editions of vista.
>> > If that requires SQL Server 2005 SP2 to install/run on Vista, will that
>> > be
>> > OK connecting to SP1 servers?
>> Yes
>> > Sorry to ask such dumb questions, but some googling of the site and
>> > newsgroups has not sufficiently enlightened me.
>> >
>> > Thanks.
>> >
>> > Josh
>> >
>>|||Ohhh. Just as well, probably need to upgrade the ol' workstation anyway.
Josh
"Andrew J. Kelly" wrote:
> You can wait until March but you won't have 2008:). It isn't set to
> actually ship until the end of 2nd quarter 2008 which is end of June. The
> launch will be in Feb but SQL Server 2008 will not be ready for shipping at
> that time.
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "JRStern" <JRStern@.discussions.microsoft.com> wrote in message
> news:E6FC84B2-D6AC-401D-BF90-DCC941D1DD33@.microsoft.com...
> > Andrew, thanks very much.
> >
> > This is in a corporate dev group, however the workstation (laptop) is
> > owned
> > by contractor. We certainly have many licensed copies of SQLServer, and
> > this
> > is for dev, so are we allowed to install client tools on ("visiting")
> > laptop?
> >
> >
> > Probably need to have contractor get own (and I need one for home, or
> > maybe
> > I should now wait until March and skip to 2008!)
> >
> > Thanks again,
> > Josh
> >
> >
> > "Andrew J. Kelly" wrote:
> >
> >> See in-line:
> >>
> >> --
> >> Andrew J. Kelly SQL MVP
> >> Solid Quality Mentors
> >>
> >>
> >> "JRStern" <JRStern@.discussions.microsoft.com> wrote in message
> >> news:499D51EE-02B3-44D1-AD00-2FFBBBEE4243@.microsoft.com...
> >> > Couple of questions about the current state of things regarding client
> >> > tools.
> >> >
> >> > Are just the client tools freely downloadable and installable, or is a
> >> > license required, or are the client tools not even available outside of
> >> > a
> >> > full product install (even if it's just express)?
> >>
> >> The full client tools come with a fully licensed product and can not be
> >> purchased seperately. If this is for devel purposes I would suggest
> >> buying
> >> the developer edition which is less than $100 and you get it all. The
> >> Express version is free but is only for Express edition of SQL Server.
> >>
> >> > (and if you happen to have the link handy ... thanks for posting it!)
> >>
> >> > Whatever has to be installed, will it work with Vista?
> >>
> >> SQL2005 SP2 works with Vista.
> >>
> >> > Does it have to be Vista Pro? (not sure which we have)
> >>
> >> Developer edition works with all editions of vista.
> >>
> >> > If that requires SQL Server 2005 SP2 to install/run on Vista, will that
> >> > be
> >> > OK connecting to SP1 servers?
> >>
> >> Yes
> >>
> >> > Sorry to ask such dumb questions, but some googling of the site and
> >> > newsgroups has not sufficiently enlightened me.
> >> >
> >> > Thanks.
> >> >
> >> > Josh
> >> >
> >>
> >>
>