title: SQL Server - sequence behind the view
body: <p>I would like to isolate query next value of the sequence on the database side so my application just needs to query from view and it obtain its unique id of process.</p>
  
  <p></p>
  
  <pre><code>CREATE SEQUENCE SEQ_VID MINVALUE 1 MAXVALUE 2147483647;
  CREATE VIEW VID AS SELECT NEXT VALUE FOR SEQ_VID AS ID;
  -- I got following error:
  -- NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, derived tables or return statements.
  </code></pre>
  
  <p>While the approach works fine on <em>postgres</em> and <em>h2</em> db it looks it will not work for sqlserver.<br>
  I've found nice post about the limitations of sequences in sql server <a href="http://sqlhints.com/2013/08/18/sequence-limitations-and-restrictions-sql-server-2012/" rel="nofollow">here</a>.  </p>
  
  <p>So the question is how can I achieve isolation of quering from sequence in case of MS sqlserver, so my application dont have to be db vendor aware?</p>