How to insert into a table, in the collumn specified as identity

Do you need something like this? I need this many times, specially when I need to syncronize two databases or life database with demo database. So..this is simple, you have to write a common insert command and other two lines, for ignoring, on insert time the identity column:

SET IDENTITY_INSERT [table_name] ON

insert into [table_name] (id, name, ...) values (99,'popnadrian')

SET IDENTITY_INSERT [table_name] OFF

And you made a "nice" work, your boss must be proud by you Wink


Posted by: admin
Posted on: 11/6/2009 at 3:40 PM
Tags: , ,
Categories: Programing | SQL
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading