CREATE UNIQUE NONCLUSTERED INDEX idx_UNC_custid_orderdate_orderid
  ON dbo.Orders(custid, orderdate, orderid)

SELECT custid,
  (SELECT COUNT(*)
  FROM dbo.Orders AS O2
  WHERE O2.custid = O1.custid
    AND (O2.orderdate < O1.orderdate
      OR (O2.orderdate = O1.orderdate
        AND O2.orderid <= O1.orderid))) AS custrownum,
  CONVERT(varchar(10), orderdate, 120) AS orderdate,
  orderid, empid, qty
FROM dbo.Orders AS O1
ORDER BY custid, orderdate, orderid