Mike Chaliy
Mike Chaliy

Reputation: 26668

SQL Business Logic Wanted

I am looking for hard to follow, large, pure readable and unsupportable SQL scripts with business logic. I need something overblown to illustrate Code vs SQL business logic. May be you have one?

Update: I am looking examples of terrible SQL. I am not looking for comparisons for these styles of business logic. May be you start task on inherited terrible SQL logic and you can share it. It could be absurd, funny or something like that. Actually, logic is not required queries are ok too.

Upvotes: 0

Views: 366

Answers (4)

Steven A. Lowe
Steven A. Lowe

Reputation: 61233

a fair comparison would show the same business logic in code vs sql

anything else is comparing apples to oranges - or worse, stacking the deck to support a foregone conclusion

Upvotes: 1

Juliet
Juliet

Reputation: 81516

I've posted a few nasty bits of SQL I've encountered in the real world:

Embedding UI Logic in stored procedures

A sorry excuse for a database search (near the bottom of that post)

Maybe a simpler example would be using a cursor to perform functions which could be more easily accomplished using basic SQL. For example compare simple query using a WHERE or GROUP BY clause to a stored procedure which implements the same functionality using cursor.

Upvotes: 0

Robin Day
Robin Day

Reputation: 102478

Having bad SQL to prove your point will not work as it doesn't prove anything other than people can write bad SQL. There can be bad code that does the exact opposite to what you want to prove.

You might want to look into describing the abilities of the development team in place. If coding is their strong point rather than SQL then that is the route that should be taken.

Upvotes: 0

Joel Coehoorn
Joel Coehoorn

Reputation: 415820

Anything with a trigger. They hide code off in unexpected places and create side effects that can be difficult to debug. Of course, triggers have their place, but you definitely need to use them with caution.

Upvotes: 2

Related Questions