Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 A typical query help req.

Author  Topic 

maqk
Starting Member

1 Post

Posted - 2007-08-02 : 07:50:40
I want to delete all those rown from a table who have same value for a field (the col was supposed to be unique - NOT PK though) & those rows PK are not present as a FK in another table

well its all so confusing so let metell in simple words

Table-1 - 'CM-Company_Master' [Primary Table]
Table-2 - 'CY-Company_Years' [Primary Table]

CM.comapny_id is FK in CY table

CM has another field - Company_Code - This field is supposed to be UNIQUE but unfortunately the data is inconsistent as NO CONSTRAINT was enforced earlier in the DB Design

there are rows iun CM table who have inconsistent data in the table (samevalue for 'company_code' field)but has no reference in the CY table cause when the data was entered by the DEOs, some company data got entered twice

now i want to delete those rows who have inconsistent data in the table & has no reference in the CY table cause when the data was entered by the DEOs, some company data got entered twice

please help

MAQK - One true Lord exists
   

- Advertisement -