title: Msg 13536, Level 16, State 1, Line 133 [Batch Start Line 7]
body: <p>I have a stored-procedure, When I run it I get an error as follows:</p>
  
  <blockquote>
    <p>Cannot insert an explicit value into a GENERATED ALWAYS column in
    table 'CAS2.dbo.Tree'. Use INSERT with a column list to
    exclude the GENERATED ALWAYS column, or insert a DEFAULT into
    GENERATED ALWAYS column.</p>
  </blockquote>
  
  <pre><code>USE [Test]
  GO
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER PROCEDURE [dbo].[sp_InsertDiagramData]
      @DiagramId varchar(100) ,
      @DiagramName NVARCHAR(200) ,
      @DiagramClass varchar(50),
      @DiagramPosition varchar(100) = NULL,
      @IsReadonly BIT = 0 ,
      @CreatorUserId INT ,
      @Nodes Node READONLY ,
      @NodesDetail Detail READONLY,
      @Links Link READONLY
  AS
      BEGIN TRY
          BEGIN TRANSACTION
  
              IF(@DiagramId IS NOT NULL)
                  BEGIN
                   -- Clear old data
                      DELETE  FROM dbo.Links WHERE   DiagramId = @DiagramId;
                      DELETE  FROM dbo.Nodes WHERE   DiagramId = @DiagramId;
                      DELETE  FROM dbo.Diagrams WHERE Id = @DiagramId;
                  DELETE  FROM dbo.NodesDetails WHERE DiagramId = @DiagramId;
                    -- Business table
     DELETE FROM dbo.WorkStationToProduct WHERE ExpenseCenterId = @DiagramId
                  END 
      ELSE
                  SET @DiagramId = NEWID()
  
      -- Insert into Tree and TreeDetails table
  
      DECLARE @DetailsId INT
      DECLARE @OutputMaster TABLE (id INT);
  
      INSERT  INTO dbo.Tree
                      ( Number ,
                        ParentProductId ,
                        Scale ,
                        FinalHumidityPercent ,
                        UnitId ,
                        Setting ,
                        ModifiedDate ,
                        SysStartTime ,
                        SysEndTime ,
                        UserId ,
                        ComputerName ,
                        flag ,
                        ConfirmUserId
                      )
      -- here you will store the bulk inserted id's 
      OUTPUT inserted.Id into @OutputMaster(id)
      SELECT  a.NodeId [Number], f.Value [ParentProductId], h.Value [Scale], 
              g.Value [FinalHumidityPercent],  i.Value [UnitId],
              0 [Setting], dbo.[fnMiladiToShamsi](GetDate()) [ModifiedDate], 
              SYSDATETIME() [SysStartTime] ,SYSDATETIME() [SysEndTime] ,
              @CreatorUserId [UserId], HOST_NAME() [ComputerName], '0' [flag], 
              'NULL' [ConfirmUserId]
      FROM dbo.NodesDetails a 
      LEFT JOIN dbo.NodesDetails b ON  a.NodeId = b.NodeId AND b.[Key] = 
             'ChildProductId'
      LEFT JOIN dbo.NodesDetails c ON  a.NodeId = c.NodeId AND c.[Key] =                 
             'InUseValue'
      LEFT JOIN dbo.NodesDetails d ON  a.NodeId = d.NodeId AND d.[Key] = 
             'Mammock'
      LEFT JOIN dbo.NodesDetails e ON  a.NodeId = e.NodeId AND e.[Key] = 
             'MaterialTypeId'
      LEFT JOIN dbo.NodesDetails f ON  a.NodeId = f.NodeId AND f.[Key] = 
             'ParentProductId'
      LEFT JOIN dbo.NodesDetails g ON  a.NodeId = g.NodeId AND g.[Key] = 
             'FinalHumidityPercent'
      LEFT JOIN dbo.NodesDetails h ON  a.NodeId = h.NodeId AND h.[Key] = 
             'Scale'
      LEFT JOIN dbo.NodesDetails i ON  a.NodeId = i.NodeId AND i.[Key] = 
             'UnitId'
      WHERE a.DiagramId = @DiagramId 
                  AND a.[Key] = 'ParentProductId' 
                  AND a.Value IN 
                (SELECT x.Value FROM dbo.NodesDetails x 
                 WHERE 
                 x.[Key]='ProductId' AND x.DiagramId = @DiagramId)
      ORDER BY a.NodeId;
  
      SELECT * FROM dbo.Diagrams WHERE Id = @DiagramId
  
          COMMIT TRANSACTION   
      END TRY
      BEGIN CATCH
          ROLLBACK TRANSACTION;
  
          THROW;
      END CATCH;
  </code></pre>
  
  <p>I'm tired of searching the Internet for the above error.  I will be grateful if someone help me.</p>