Lab Qeustion (What im missing?)

  • I have the following Code
    INSERT INTO dbo.Region (RegionID, RegionDescription)
    VALUES (5, 'Space')

    select RegionID, RegionDescription
    from dbo.Region
    where regionID = 5
    /*
    and trying
    SELECT SCOPE_IDENTITY();
    */

    But getting the following tip:

    Table look like this:

  • Please post the DDL script for the table. I think the insert operation is not happening successfully. Do you have IDENTITY set in the RegionID column?

  • debasis.yours - Tuesday, July 24, 2018 1:24 AM

    Please post the DDL script for the table. I think the insert operation is not happening successfully. Do you have IDENTITY set in the RegionID column?

    SET IDENTITY_INSERT RegionID ON;

    INSERT INTO Region (RegionID, RegionDescription)
    VALUES (5, 'Space');

    SET IDENTITY_INSERT RegionID OFF;

    select RegionID, RegionDescription
    from dbo.Region
    where RegionID = 5

    I have  try this but still get the same error..

  • Hi,
    You have a wrong statement here. In the below statement, you have used column name in place of the expected table name. Please check.
    SET IDENTITY_INSERT <TableName> ON;
    SET IDENTITY_INSERT <TableName> OFF;

    Also, please check what value you are getting by this:
    SELECT IDENT_CURRENT('Region')

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply