Sunday, November 9, 2014

HOW TO DELETE TWO NULL VALUES IN A TABLE

CREATE TABLE GGGG(ID VARCHAR(50))

INSERT INTO GGGG VALUES('A'),('B'),('C'),('D'),(NULL),(NULL),(NULL),(NULL)

SELECT * FROM  GGGG

;WITH X AS(SELECT ID,ROW_NUMBER() OVER(PARTITION BY ID ORDER BY ID) AS ROW_NO FROM GGGG)

---SELECT * FROM X

DELETE FROM X WHERE ID IS NULL AND ROW_NO IN(1,2)

No comments:

Post a Comment