Home Forums SQL Server 2008 T-SQL (SS2K8) How can I set identity_insert on a tablename passed to an sproc RE: How can I set identity_insert on a tablename passed to an sproc

  • Don i think your EXC command needs to do everything all together; you can separate commands with a semi colon, which is rumored to be mandatory in a future version of SQL.

    this works for example:

    CREATE TABLE IDDemo

    ( pk_ID Integer IDENTITY(1,1)

    , Textdata Varchar(100) )

    EXEC ('SET IDENTITY_INSERT IDDemo ON;INSERT IDDemo (pk_ID, Textdata) Values (4, ''This works too'');SET IDENTITY_INSERT IDDemo OFF;')

    SELECT * FROM IDDemo

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!