Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed


follow us on Twitter





New Security Features Planned for Firefox 4

Another Laptop Theft Exposes 21K Patients' Data

Oracle Hits to Road to Pitch Data Center Plans
Database Journal |DBA Support |SQLCourse |SQLCourse2









Systems Programmer / Software Engineer - C, Unix-Linux, Multi-threading, IPC
WSI Nationwide, Inc.
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

MS SQL

Aug 24, 1999

SQL Sam and the Evil Twin - Part 1 - Page 2

By Steve Hontz

SQL Sam and the Evil Twin - Part 2

Environment: SQL Server 6.5, SP4

Sam and Fred examined the SQL Trace from both machines. "You're right, " said Sam. "On Beanie, sp_FindProducts is averaging about 50 milliseconds. On Cecil, though, the query is taking around 250 milliseconds. It's taking 5 times as long!"

"See?" said Fred. "Cecil's gone bad!"

"Let's take a look at your stored procedure," said Sam.

Fred brought the procedure up in Enterprise Manager. It looked something like this:

CREATE PROCEDURE sp_FindProducts
@TYPE varchar(20),
@ARG1 varchar(20),
          
...detail omitted...
          
IF @TYPE = 'HOUSE'
BEGIN
SELECT * FROM products WHERE color = @ARG1
END
ELSE -- Must be of type 'BUSINESS'
BEGIN
SELECT * FROM products WHERE price < convert(money(8), @ARG1)
END

"Interesting," said Sam. "Why is the procedure constructed this way? How is ARG1 used?"

"Actually, it's pretty clever. We found that when people are looking for household products, the most important option is the color. When people are looking for business products, the most important option is the price. So, we combined the two into one procedure, passing either a color or a price as ARG1."

"Did you by any chance try this procedure on Cecil before starting the Do-It-All application?" asked Sam

"Why yes," said Fred. "I wanted to make sure that the 'BUSINESS' products were working properly. Why?"

"I think I know what the problem is now," said Sam. "Let's check."

What did SQL Sam see? Go to the solution now!

Review SQL Sam and the Evil Twin - Part 1

Back to SQL Sam Cases


Steve Hontz is President of The Bit Corner, Inc., a Phoenix-based consulting firm specializing in Windows NT, C++, and SQL Server development. You can reach him at steve@bitcorner.com.


Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 



Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server – Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM