I would suggest you to redesign your table!
Use
ALTER TABLE[
^] command to update productid to not accept null values.
Here is one-usage solution:
DECLARE @tmp TABLE (productId INT NULL, productname VARCHAR(30) NULL, enterdate DATETIME, [status] INT)
SET DATEFORMAT dmy;
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(1, 'lux', '1/1/2013', 0)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(2, 'santoor', '2/1/2013', 0)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(3, 'colgate', '2/1/2013', 0)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(4, 'mouse', '2/1/2013', 0)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(null, null, '3/1/2013', 1)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(6, 'keyboard', '6/1/2013', 0)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(null, null, '7/1/2013', 1)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(8, 'speakers', '8/1/2013', 0)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(9, 'pen', '9/1/2013', 0)
INSERT INTO @tmp (productId, productname, enterdate, [status])
VALUES(10, 'cellphone', '10/1/2013', 0)
INSERT INTO @tmp (productId, productname, enterdate, [status])
SELECT t1.productid, t1.productname, t2.enterdate, t2.status
FROM @tmp AS t1 INNER JOIN (
SELECT enterdate, [status]
FROM @tmp
WHERE productId IS NULL AND productname IS NULL
) AS t2 ON t1.enterdate = DATEADD(dd,-1,t2.enterdate)
WHERE t1.productId IS NOT NULL AND t1.productname IS NOT NULL
DELETE
FROM @tmp
WHERE productId IS NULL AND productname IS NULL
SELECT *
FROM @tmp
ORDER BY enterdate, productid
Result:
1 lux 2013-01-01 00:00:00.000 0
2 santoor 2013-01-02 00:00:00.000 0
3 colgate 2013-01-02 00:00:00.000 0
4 mouse 2013-01-02 00:00:00.000 0
2 santoor 2013-01-03 00:00:00.000 1
3 colgate 2013-01-03 00:00:00.000 1
4 mouse 2013-01-03 00:00:00.000 1
6 keyboard 2013-01-06 00:00:00.000 0
6 keyboard 2013-01-07 00:00:00.000 1
8 speakers 2013-01-08 00:00:00.000 0
9 pen 2013-01-09 00:00:00.000 0
10 cellphone 2013-01-10 00:00:00.000 0