Lm th? no ? lo?i b? trng l?p hng t? m?t b?ng SQL Server b?ng cch s? d?ng m?t k?ch b?n

D?ch tiu ? D?ch tiu ?
ID c?a bi: 70956 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

TM T?T

B?n c th? s? d?ng k?ch b?n sau y ? lo?i b? trng l?p hng t? m?t Microsoft SQL H? ph?c v? bn:
   SELECT DISTINCT *
      INTO duplicate_table
      FROM original_table
      GROUP BY key_value
      HAVING COUNT(key_value) > 1

   DELETE original_table
      WHERE key_value
      IN (SELECT key_value
             FROM duplicate_table)

   INSERT original_table
      SELECT *
         FROM duplicate_table

     DROP TABLE duplicate_table
				
Khi k?ch b?n ny ?c thi hnh, n theo cc b?c sau:
  1. N di chuy?n m?t tr?ng h?p c?a b?t k? hng trng l?p trong Ban ?u b?ng vo m?t b?ng trng l?p.
  2. N xa t?t c? cc hng t? b?ng ban ?u c?ng n?m trong b?ng trng l?p.
  3. N di chuy?n cc cc hng trong b?ng trng l?p tr? l?i vo ban ?u b?ng.
  4. N xu?ng b?ng trng l?p.

THNG TIN THM

Phng php ny r?t n gi?n. Tuy nhin, n ?i h?i r?ng b?n c ? khng gian s?n dng trong c s? d? li?u ? t?m th?i xy d?ng b?n sao b?ng.

Thu?c tnh

ID c?a bi: 70956 - L?n xem xt sau cng: 17 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Express Edition
  • Microsoft SQL Server 2005 Workgroup Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2000 Personal Edition
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 2000 Workgroup Edition
  • Microsoft SQL Server 2000 Developer Edition
  • Microsoft SQL Server 2000 Enterprise Edition
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 6.5 Standard Edition
  • Microsoft SQL Server 6.0 Standard Edition
  • Microsoft SQL Server 4.21a Standard Edition
T? kha:
kbprogramming kbmt KB70956 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:70956

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com