Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: SQL Server2000 - Deleting Duplicate records- HELP!!


Message #1 by melissa.knight@d... on Thu, 17 Jan 2002 19:44:09
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C19FA7.660AE770
Content-Type: text/plain;
	charset="iso-8859-1"

thanks for the input!
 

melissa.knight@d... 

-----Original Message-----
From: David Cameron [mailto:dcameron@i...]
Sent: Thursday, January 17, 2002 4:34 PM
To: sql language
Subject: [sql_language] RE: SQL Server2000 - Deleting Duplicate record s- H
ELP!!



This group of SQL statements uses a little more system resources than is
really needs and uses some (IMO) bad programming practices.

Performance hits 
1. TEMP is actually a full table, rather than a temp table. What you want to
do is create a temp table as they use less overhead. A temp table is
prefixed by a #.

Bad practices 
1. *All* table and field names should contain only a-z, A-Z, 0-9. *Never*
spaces. Very messy and forces you to use [] which just bloats the whole
thing. This can cause a lot of errors because people do not expect spaces.
Don't just take it from me:

<quote Source="Wrox Professional SQL Server 7 programming, p146"> 
Beginning with SQL Server 7 it is also an option to separate words in the
name using a regular space. ... it is an extremely bad practice and causes
an unbelievable number of errors. ... I curse the person(s) who decided to
put it in...

</quote> 
2. The identity field should not be called ID. First of all this is not very
descriptive and secondly it one of those names that is likely to be used by
internal processes. It is not a reserved keyword, but IMO it should be, if
just to stop people using it.

3. I would avoid using words like First and Last as field names. You need to
be very careful you don't use reserved keywords. Personally I give all my
fields (apart from the ID) a 3 letter prefix to specify what datatype the
field has (eg int, txt, dtm, bit)

That said, I created your sales table and ran a test of your script and the
only error I had was based on the fact that you were using the reserved
keyword TEMP for the name of your temp table. Assuming that all your field
names are correct (and you said you checked them)  everything should work.

regards 
David Cameron 
nOw.b2b 
dcameron@i... 

$subst('Email.Unsub'). 



  Return to Index