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.

 All Forums
 Site Related Forums
 The Yak Corral
 Die Cursors... Die!

Author  Topic 

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-06-29 : 16:37:13
How would I go about raising an error anytime someone (an application developer) tries to create a cursor in my database?

Something along the lines of:

RAISERROR ('Are you kidding me? Did you think I was going to stand by and let you completely destroy this database? Please call x1988 immediately, you moron.', 16, 1)


Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-06-29 : 16:47:19
If they are creating them in stored procedures you can always query the text column in syscomments and replace their code with "What are you doing you overpaid dumbass?"

For inline you are going to have to run searches on their sourcecode or use profiler I guess.

Sean Roussy

Please backup all of your databases including master, msdb and model on a regular basis. I am tired of telling people they are screwed. The job you save may be your own.

I am available for consulting work. Just email me though the forum.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-06-29 : 16:47:55
hmm... nice thought. Don't know how you would do that.

Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-06-29 : 16:58:39
For now, I have been searching for keywords "Fetch Next" etc... and if I catch one quick enough ill give them a call and freak em out.

<ring>
<ring>

app developer: "Hello"

me: <long pause>

app developer: "... Hello??"

me: <deep breath> <exhale into phone> "Did you think I wouldnt notice?"





Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-06-29 : 17:55:31
quote:
Originally posted by nathans

For now, I have been searching for keywords "Fetch Next" etc... and if I catch one quick enough ill give them a call and freak em out.

<ring>
<ring>

app developer: "Hello"

me: <long pause>

app developer: "... Hello??"

me: <deep breath> <exhale into phone> "Did you think I wouldnt notice?"




You can run but you cant hide...know what else is annoying seeing a bunch of wheres when you prolly should of joined, i just hate that :(.



Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]
Imperfection living for perfection --
[url]http://jhermiz.blogspot.com/[/url]
Go to Top of Page

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2005-06-30 : 10:01:21
Personally I love cursors. I wrap my print statements around cursors just for fun.

DECLARE @intID int
DECLARE curI_Love_Cursors INSENSITIVE CURSOR FOR
SELECT TOP 1 intAjthepoolmanID
FROM A_Table


OPEN curI_Love_Cursors

FETCH NEXT FROM curI_Love_Cursors INTO @intID
WHILE (@@FETCH_STATUS <> -1)
BEGIN

PRINT CAST(@intID AS VARCHAR(50))

FETCH NEXT FROM curI_Love_Cursors INTO @intID

END

CLOSE curI_Love_Cursors
DEALLOCATE curI_Love_Cursors


Aj
Go to Top of Page

Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-06-30 : 12:13:11
I am not starting this beaten weathered tired debate today. All I have to say is go to google and type in "SQL Server cursors are bad" and do not stop reading until you are convinced.

Ok I have a couple more quick things to say. They are not needed 99.99% of the time they are used. They bog down servers. Programmers worth their salt used set based solutions instead.

Sean Roussy

Please backup all of your databases including master, msdb and model on a regular basis. I am tired of telling people they are screwed. The job you save may be your own.

I am available for consulting work. Just email me though the forum.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-06-30 : 13:10:09
"Please backup all of your databases including master, msdb and model on a regular basis"

Do I need a cursor for that?

Kristen
Go to Top of Page

Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-06-30 : 13:30:58
quote:
Originally posted by Kristen

"Please backup all of your databases including master, msdb and model on a regular basis"

Do I need a cursor for that?

Kristen



I am not in a silly mood today. Stayed up too late last night. I added that too my signature because I am tired of people posting this question:

"Heh, I have not backed up my database in 4 or 5 months, I truncated my transaction log because it was getting too big yesterday and last night my RAID 0 drive where I was keeping all of my data files crashed and burned. Can I get my database back to where it was last night about 8pm. DDDDDDDAAAAAARRRRRRRRR."

Sean Roussy

Please backup all of your databases including master, msdb and model on a regular basis. I am tired of telling people they are screwed. The job you save may be your own.

I am available for consulting work. Just email me though the forum.
Go to Top of Page

ajthepoolman
Constraint Violating Yak Guru

384 Posts

Posted - 2005-06-30 : 14:18:19
Sorry to hear you had a late night. We're just messin' with ya!

I used to rely on cursors to do the data migrations from other company's systems. You know, it was convenient to hold on to primary keys and such while inside a looping structure. I believe it was on this forum that I asked for help because a migration script I had written was taking over 7 days to run. Yes, that is an entire week.

The fine folks here opened my eyes. I rewrote the script and modified tables to hold IDs, and would then drop the columns when I was done with a certain ID. I am not kidding here when I tell you that the same script that took 7 days via cursors, ran in 38 minutes after the rewrite. I was absolutely amazed at what a difference it made.

I still use a couple of cursors, but they are not a part of any regularly used stored procs. They are used more for the homemade wizards that we wrote.

Hope that tomorrow is always better than yesterday.

Aj
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2005-06-30 : 19:34:56
quote:
Originally posted by Thrasymachus

I am not starting this beaten weathered tired debate today. All I have to say is go to google and type in "SQL Server cursors are bad" and do not stop reading until you are convinced.



Nobody really asked you to start it, it seems to me that everyone else was having a perfectly fun time already.





Damian
"A foolish consistency is the hobgoblin of little minds." - Emerson
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2005-06-30 : 19:38:06
CURSORS ROCK

DavidM

A front-end is something that tries to violate a back-end.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-07-01 : 01:32:16
cursors = con$ultancy

Kristen
Go to Top of Page
   

- Advertisement -