dbTalk Databases Forums  

strange behavior with SP

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss strange behavior with SP in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wishmaster
 
Posts: n/a

Default strange behavior with SP - 05-05-2011 , 09:54 AM






Hi everyone,

I got this situation, I got a stored procedure that for some reason
after using it for some period of time (maybe a day or two) stops
sending results, but if I change the position of the condition (where)
on the first line then begins to work ok. This solution works a day or
two but the issue arise again and I must change the line to it's
original version, completing this weird cycle. have you ever seen this
kind of behavior before?
The first commented line is what i need to change time to time...


--Where (Cr.ID_Credito = @ID_Credito Or @ID_Credito = 0)
Where (@ID_Credito = 0 Or Cr.ID_Credito = @ID_Credito)
And (Co.Rut_Cliente = @Rut_Cliente Or @Rut_Cliente = '')
And (Cr.Estado_Credito = @Estado_Credito Or @Estado_Credito = '')
And (Cr.Confirmado= @Confirmado or @Confirmado='')
And (Cr.Estado_Credito in
('CP','AN','CE','CA','EO','AC','CO','CR','CD','JU' ))
And (Cr.Rut_Empresa = @Rut_Empresa Or @Rut_Empresa = '')
and (Co.Codigo_Local=@Codigo_Local or @Codigo_Local=0)
and (Cr.Automotora=@Rut_Automotora or @Rut_Automotora='')
and (PE.Rut_persona=@Rut_Persona or @Rut_Persona='')
and (Cr.Confirmado = @Confirmado or @Confirmado='')
and (Cr.Garantizado = @Garantizado or @Garantizado='')


Thanks.
Diego.

ASP, Com+
SQL Server 2005 SP3

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: strange behavior with SP - 05-05-2011 , 04:56 PM






Wishmaster ("sysadmin.rock[SINESTO]"@gmail.com) writes:
Quote:
I got this situation, I got a stored procedure that for some reason
after using it for some period of time (maybe a day or two) stops
sending results, but if I change the position of the condition (where)
on the first line then begins to work ok. This solution works a day or
two but the issue arise again and I must change the line to it's
original version, completing this weird cycle. have you ever seen this
kind of behavior before?
The first commented line is what i need to change time to time...
What more exactly do you mean with stop sending results? Does it not
produce a result set at all? Does it only produce an empty result set?
Is there an error message?

What happens if you run the procedure from Management Studio? If you run
the procedure from Mgmt Studio, after first having executed SET ARITHABORT
OFF?

Anyway, I would suggest that you add this at the end of the query:

OPTION (RECOMPILE)

Since I assume that this is somehow related to the query plan, I expect that
this should resolve the issue. I would also expect it to improve the overall
performance.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Reply With Quote
  #3  
Old   
Wishmaster
 
Posts: n/a

Default Re: strange behavior with SP - 05-06-2011 , 03:22 PM



On 05-05-2011 18:56, Erland Sommarskog wrote:
Quote:
Wishmaster ("sysadmin.rock[SINESTO]"@gmail.com) writes:
I got this situation, I got a stored procedure that for some reason
after using it for some period of time (maybe a day or two) stops
sending results, but if I change the position of the condition (where)
on the first line then begins to work ok. This solution works a day or
two but the issue arise again and I must change the line to it's
original version, completing this weird cycle. have you ever seen this
kind of behavior before?
The first commented line is what i need to change time to time...

What more exactly do you mean with stop sending results? Does it not
produce a result set at all? Does it only produce an empty result set?
Is there an error message?

What happens if you run the procedure from Management Studio? If you run
the procedure from Mgmt Studio, after first having executed SET ARITHABORT
OFF?

Anyway, I would suggest that you add this at the end of the query:

OPTION (RECOMPILE)

Since I assume that this is somehow related to the query plan, I expect that
this should resolve the issue. I would also expect it to improve the overall
performance.

Erland,

what i'm trying to say is there not any result set on my website and no
error message as well. But if i run the stored procedure from Mgnt
Studio takes arround 3 minutes to produce a result set.
I'm going to check your suggestions.
Thank you!

Diego.

Reply With Quote
  #4  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: strange behavior with SP - 05-06-2011 , 04:52 PM



Wishmaster ("sysadmin.rock[SINESTO]"@gmail.com) writes:
Quote:
what i'm trying to say is there not any result set on my website and no
error message as well. But if i run the stored procedure from Mgnt
Studio takes arround 3 minutes to produce a result set.
I'm going to check your suggestions.
Three minutes is a tad long for a search from a web page. Since the default
timeout in most client API is 30 seconds, I suspect that you get a timeout.

I have an article on my web site that discusses various strategies
for these kind of searches, including the one you are using.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Reply With Quote
  #5  
Old   
Wishmaster
 
Posts: n/a

Default Re: strange behavior with SP - 05-09-2011 , 01:55 PM



On 06-05-2011 17:52, Erland Sommarskog wrote:
Quote:
Wishmaster ("sysadmin.rock[SINESTO]"@gmail.com) writes:
what i'm trying to say is there not any result set on my website and no
error message as well. But if i run the stored procedure from Mgnt
Studio takes arround 3 minutes to produce a result set.
I'm going to check your suggestions.

Three minutes is a tad long for a search from a web page. Since the default
timeout in most client API is 30 seconds, I suspect that you get a timeout.

I have an article on my web site that discusses various strategies
for these kind of searches, including the one you are using.


Erland,

This morning it happened again, but we research it about the recompile
option that you suggested and we used it. Now i'm going to track this
particular issue. I will tell you how it goes later.
Thanks,

PD: what is the link of your website?

Reply With Quote
  #6  
Old   
Henk van den Berg
 
Posts: n/a

Default Re: strange behavior with SP - 05-09-2011 , 02:20 PM



Wishmaster schreef op 09-05-2011 20:55:
Quote:
Thanks,

PD: what is the link of your website?



http://www.sommarskog.se/

Reply With Quote
  #7  
Old   
Wishmaster
 
Posts: n/a

Default Re: strange behavior with SP - 05-09-2011 , 03:45 PM



On 09-05-2011 15:20, Henk van den Berg wrote:
Quote:
Wishmaster schreef op 09-05-2011 20:55:
Thanks,

PD: what is the link of your website?




http://www.sommarskog.se/
thanks Henk.

Reply With Quote
  #8  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: strange behavior with SP - 05-09-2011 , 04:52 PM



Wishmaster ("sysadmin.rock[SINESTO]"@gmail.com) writes:
Quote:
PD: what is the link of your website?
Oops! Forgot to paste the link: http://www.sommarskog.se/dyn-search.html

My sincere apologies.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.