Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 1st, 2007, 01:12 PM
zodiac7 zodiac7 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 2 zodiac7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m
Reputation Power: 0
SQL Server 2000 SP 4 issue with query

This query executes (instantly) in SQL Server 2000 without SP4. With SP 4, it hangs - goes over 5 mins and does nothing. If we make the following change to the query: (replace the variables with actual values)
...
where Links.Matter_ID = 5872

AND Links.Entity_ID = 1

Order By Contacts.ContactID
...
It executes almost instantly in SP4 as well.
Looks like a SP4 issue, any ideas on how we could fix this?
t-sql follows:

Declare @MatterID bigint

Declare @EntityID int

Declare @ReturnDetails int

Declare @RETVAL VarChar(8000)

Declare @EntityDetails VarChar(1000)



Set @MatterID = 5875

Set @EntityID = 1

Set @ReturnDetails = 0

DECLARE Entity_Cursor CURSOR FOR

Select CASE WHEN Contacts.Job_Title IS Null Then '' Else Contacts.Job_Title + ' ' End + CASE WHEN Contacts.First_Name IS Null Then '' Else Contacts.First_Name + ' ' End + CASE WHEN Contacts.Middle_Name IS Null Then '' Else Contacts.Middle_Name + ' ' End



+ CASE WHEN Contacts.Last_Name IS Null Then '' Else Contacts.Last_Name End EntityDetails

From Links

INNER JOIN Contacts

On Links.Contact_ID = Contacts.ContactID

where Links.Matter_ID = @MatterID

AND Links.Entity_ID = @EntityID

Order By Contacts.ContactID



OPEN Entity_Cursor

FETCH NEXT FROM Entity_Cursor INTO @EntityDetails

Select @RETVAL = ''

WHILE @@FETCH_STATUS = 0

BEGIN

Print 'test'

/* If @ReturnDetails = 1

Select @RETVAL = @RETVAL + @EntityDetails + '
'

Else

Select @RETVAL = @RETVAL + @EntityDetails + ', '

FETCH NEXT FROM Entity_Cursor INTO @EntityDetails */

END



CLOSE Entity_Cursor

DEALLOCATE Entity_Cursor

Reply With Quote
  #2  
Old February 5th, 2007, 06:35 AM
zodiac7 zodiac7 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 2 zodiac7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m
Reputation Power: 0
progress...

ok, the original sql works fine if I change the cursor type to static forward-only

I just changed the line
DECLARE Entity_Cursor CURSOR
To
DECLARE Entity_Cursor static forward-only CURSOR

but now I have a bunch of sps which could all fail because they are like this, Is there a way to tell sql server to have all default (no type specified) cursors created as 'static forward-only', I couldn't find a way to do this using sp_configure so any suggestions would be appreciated.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > SQL Server 2000 SP 4 issue with query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT