Exists and Expand wildcards

Refactors and formats SQL code.

Moderators: Chris Auckland, David Atkinson, Anu Deshpande, Luke Jefferson

Exists and Expand wildcards

Postby netblazer » Wed Sep 10, 2008 7:34 pm

I had a happy (Select * FROM) DBA that wrote me a 4000 line script. I useed SQL Refactor to clean up the script and it worked great... except for this :

I had a few sections like this:

IF EXISTS (SELECT * FROM dbo.Clients)
BEGIN
SELECT 1 AS TEST
END
ELSE
BEGIN
SELECT 0 AS TEST
END

And when hitting the expand wildcard option, all the exists had the full columns listed. Now I know it doesn't change anything eprformance wise but I still see this as useless visual noise. I would be awesome if Refactor could recognize the exists and ignore the wildcard in the next parenthesis.
netblazer
 
Posts: 3
Joined: Sun Sep 09, 2007 3:57 pm

Postby Ben Pinchen » Mon Sep 15, 2008 2:56 pm

Thanks for the feedback. I've raised this as a feature request and the developers will look into this when they work on a future version of the software. For your reference the feature request tracking code is: SR-824
Ben Pinchen
 
Posts: 157
Joined: Thu Dec 28, 2006 1:21 pm
Location: Red Gate

Postby ray.herring@hotmail.com » Wed Oct 29, 2008 4:37 pm

I have seen references that advise not using Select * in an exist clause. I believe the recommendation is to use "If exists (Select 1 from myTab where ..)" As I recall there is a slight but measurable performance gain.
ray.herring@hotmail.com
 
Posts: 2
Joined: Wed Oct 29, 2008 4:30 pm
Location: US - Tx


Return to SQL Refactor 1

Who is online

Users browsing this forum: No registered users and 0 guests