Skip to main content
Participant
May 14, 2009
Answered

IDENTITY_INSERT Error

  • May 14, 2009
  • 1 reply
  • 2346 views

We have recently migrated to Coldfusion 8 and have found that certain ALTER SQL commands that ran just fine in our old Coldfusion 7 environment will generate errors in CF8. We verified that all permission are given in both Coldfusion 8 Administrator Datasource Settings and SQLServer 2005 for ALTER rights to this table but we continue to get the following error.

[Macromedia][SQLServer JDBC Driver][SQLServer]Cannot find the object "dbo.SCI_Group" because it does not exist or you do not have permissions.

Here is our SQL Query that we are executing:

      DECLARE @BaSE INT
      DECLARE @fyr INT
     
      SET @BaSE = IDENT_CURRENT('dbo.SCI_Group')
      SET @fyr = 2009
     
      SET IDENTITY_INSERT dbo.SCI_Group ON
     
      INSERT INTO SCI_Group
        (ID, ParID, OldID, DowID, FYR, Name, Sort, Description, f_Input, f_Output, f_Enabled, f_Parent)
        SELECT
        ID + @BaSE,
        ParID + @BaSE,
        ID,
        DowID,
        @fyr,
        Name,
        Sort,
        Description,
        f_Input,
        f_Output,
        f_Enabled,
        f_Parent
      FROM
        SCI_Group
      WHERE
        FYR = (@fyr - 1)
       
     
      SET IDENTITY_INSERT dbo.SCI_Group OFF

Any insight from prior experience on this error type is much appreciated.

Thanks!

Mike

This topic has been closed for replies.
Correct answer JR__Bob__Dobbs-qSBHQ2

Things to check:

1. Does the code execute correctly without SET IDENTITY_INSERT statements?

2. Check permissions for your login.  From the Microsoft documentation for SET IDENTITY_INSERT: "User must own the object, or be a member of the sysadmin fixed server role, or the db_owner and db_ddladmin fixed database roles."
http://msdn.microsoft.com/en-us/library/ms188059(SQL.90).aspx

From the Microsoft documentation for IDENT_CURRENT: "Returns NULL on error or if a caller does not have permission to view the object. In SQL Server 2005, a user can only view the metadata of securables that the user owns or on which the user has been granted permission. This means that metadata-emitting, built-in functions such as IDENT_CURRENT may return NULL if the user does not have any permission on the object. For more information, see Metadata Visibility Configuration and Troubleshooting Metadata Visibility."
http://msdn.microsoft.com/en-us/library/ms175098(SQL.90).aspx

3. Can you wrap your SQL into a stored procedure and using that instead of using a batch of SQL statements?


Were there any database, network, or ColdFusion changes in the upgrade other then the move from CF7 to CF8?

1 reply

JR__Bob__Dobbs-qSBHQ2Correct answer
Inspiring
May 14, 2009

Things to check:

1. Does the code execute correctly without SET IDENTITY_INSERT statements?

2. Check permissions for your login.  From the Microsoft documentation for SET IDENTITY_INSERT: "User must own the object, or be a member of the sysadmin fixed server role, or the db_owner and db_ddladmin fixed database roles."
http://msdn.microsoft.com/en-us/library/ms188059(SQL.90).aspx

From the Microsoft documentation for IDENT_CURRENT: "Returns NULL on error or if a caller does not have permission to view the object. In SQL Server 2005, a user can only view the metadata of securables that the user owns or on which the user has been granted permission. This means that metadata-emitting, built-in functions such as IDENT_CURRENT may return NULL if the user does not have any permission on the object. For more information, see Metadata Visibility Configuration and Troubleshooting Metadata Visibility."
http://msdn.microsoft.com/en-us/library/ms175098(SQL.90).aspx

3. Can you wrap your SQL into a stored procedure and using that instead of using a batch of SQL statements?


Were there any database, network, or ColdFusion changes in the upgrade other then the move from CF7 to CF8?

mdwoickeAuthor
Participant
May 15, 2009

JR,

That did the trick!!!! It was "db_ddladmin" role that was not added in our database. Boy, we were banging our heads on this one. No searches on this error turned up anywhere!

Thank you very much!!!

Mike

Inspiring
May 15, 2009

Be aware that members of the db_ddladmin role can create, alter, and drop objects in the database.  This could be a security concern.