Autogenerate identity column via Select


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. ;WITH Tens AS
  2. (
  3. SELECT 1 N UNION ALL
  4. SELECT 1 UNION ALL
  5. SELECT 1 UNION ALL
  6. SELECT 1 UNION ALL
  7. SELECT 1 UNION ALL
  8. SELECT 1 UNION ALL
  9. SELECT 1 UNION ALL
  10. SELECT 1 UNION ALL
  11. SELECT 1 UNION ALL
  12. SELECT 1
  13. )
  14.  
  15. SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 0)) RN FROM Tens

URL: http://www.sqlservercentral.com/Forums/Topic980975-338-1.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.