SHARE
TWEET

Untitled

a guest Feb 15th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. +-----------+--------------------------------------+--------------+
  2. | DesignKey |            DesignTypeGuid            | DesignNumber |
  3. +-----------+--------------------------------------+--------------+
  4. |      2312 | 4FB560B0-E867-46B2-B116-338AD48C97AC |            3 |
  5. |      2313 | 4FB560B0-E867-46B2-B116-338AD48C97AC |            7 |
  6. |      2314 | 4FB560B0-E867-46B2-B116-338AD48C97AC |            8 |
  7. +-----------+--------------------------------------+--------------+
  8.    
  9. DECLARE @CurrentChangeOrderDesignNumber INT =
  10.               (SELECT [DesignKey], [DesignNumber]
  11.                 FROM [Design]
  12.                 WHERE ParentDesignKey = @DesignKey
  13.                 AND DesignTypeGuid = @COTypeGuid ORDER BY DesignKey);
  14.    
  15. +-----------+--------------------------------------+--------------+
  16. | DesignKey |            DesignTypeGuid            | DesignNumber |
  17. +-----------+--------------------------------------+--------------+
  18. |      2312 | 4FB560B0-E867-46B2-B116-338AD48C97AC |            1 |
  19. |      2313 | 4FB560B0-E867-46B2-B116-338AD48C97AC |            2 |
  20. |      2314 | 4FB560B0-E867-46B2-B116-338AD48C97AC |            3 |
  21. +-----------+--------------------------------------+--------------+
  22.    
  23. SELECT [DesignKey], [DesignNumber],
  24.        ROW_NUMBER() OVER (PARTITION BY ParentDesignKey, DesignTypeGuid ORDER BY DesignNumber) as new_DesignNumber
  25. FROM [Design]
  26. WHERE ParentDesignKey = @DesignKey AND
  27.       DesignTypeGuid = @COTypeGuid
  28. ORDER BY DesignKey);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top