title: Creating a primary key on table Using values from other tables
body: <p>I need to create and be able to edit how the ID on a table will be created.
  Suppose I have this two tables:</p>
  
  <pre><code>CREATE TABLE [dbo].[Consecutives]
  (
          [Consecutives_ID] [INT] IDENTITY(1,1) NOT NULL,
          [Name] [VARCHAR](100) NULL,
          [Value] [INT] NOT NULL,
          [Prefix] [VARCHAR] NOT NULL,
          CONSTRAINT PK_Consecutives PRIMARY KEY (Consecutives_ID)
  );
  
  CREATE TABLE [dbo].[Users]
  (
          [User_ID] [INT] NOT NULL PRIMARY KEY,
          [LogIn] [VARCHAR](100) NULL,
          [Pass] [VARCHAR](100) NOT NULL,
          CONSTRAINT PK_Users PRIMARY KEY (User_ID)
  );
  </code></pre>
  
  <p>is there a way to create the Primary Key on the <em>Users</em> table by using the prefix and value data on the consecutives Table and increment it once it uses that value?(via a constraint? or is it only possible via stored procedures?)</p>
  
  <p>For example, having this Insert in the Consecutives table:</p>
  
  <pre><code>INSERT INTO [dbo].[Consecutives] ([Name], [Value], [Prefix]) 
  VALUES (Users, 50, "USR-")
  </code></pre>
  
  <p>and I try to create a new user, the generated USER_ID value would be "USR-50" and the Consecutives table value updates to "51"</p>