Home Forums SQL Server 2008 SQL Server Newbies IDENTITY_INSERT, and Using Alphanumeric Autoincrement Primary Key RE: IDENTITY_INSERT, and Using Alphanumeric Autoincrement Primary Key

  • kiran.vaichalkar (6/1/2013)


    Hi Folks,

    Please help me on below few queries

    My table is

    Users(ID IDENTITY(1,1) PRIMARY KEY, NAME nvarchar(10), MANGER_ID fk_User_id References ID)

    1) now im trying SET IDENTITY_INSERT USERS.ID OFF

    But error message i received is 'Cannot find the object 'Users' because it does not exists or you do not have permissions'.

    2) In case if want my PRIMARY KEY to be alphanumeric as well as autoincrementing. For example the existing values alike 'E1, E2, E3 ans so on.

    Why I am getting that error? and How to eradicate it?

    &

    How to Set our Primary KEY to Alphanumeric AutoIncrementing?

    I wonder if the table exists. The reason I say this, is that the syntax above is incorrect/incomplete. Maybe I'm wrong on this. But will it create the table if the type of the first column is not identified? You have:

    ID IDENTITY(1,1) PRIMARY KEY,

    I would write it like this:

    ID INT IDENTITY(1,1) PRIMARY KEY,

    I have never tried to do this without giving the INT type, so I don't really know if SQL Server will assume INT and is forgiving about this. But considering the error message, I am leaning to thinking no.

    Dana