all groups > sql server programming > october 2005 >
You're in the

sql server programming

group:

sql query


sql query vanitha
10/17/2005 11:20:02 PM
sql server programming:
hi friends,

my table struct is

callid line system duration
12 7 1 120
12 7 1 500
12 6 1 240

i want to implement composite pk on this table for the columns
(callid,line,system)
so first i shd eliminate the duplicates i.e delete the duplicate values

my query for pk is

delete FROM callrecords
WHERE callid =
(SELECT MIN(callid)
FROM audcallrecords as T
WHERE audcallrecords.callid = T.callid
HAVING COUNT(*)>1)

this works if the table is holding 1 column pk.

how to do this for composite pk?

pls help me to solve this.

thanks
vanitha

RE: sql query vanitha
10/18/2005 12:14:02 AM
this query gives me the result

delete FROM VSE_MigrationTest..audcallrecords WHERE callid=(SELECT
MIN(callid) FROM MigrationTest..audcallrecords as T WHERE
MigrationTest..audcallrecords.callid= T.callid and
MigrationTest..audcallrecords.line = T.line and
MigrationTest..audcallrecords.system = T.system having count(*) > 1)



[quoted text, click to view]
AddThis Social Bookmark Button