Solved

Force a value into an identity column

Posted on 2003-11-05
2
748 Views
Last Modified: 2010-08-05
How can I force a value into an identity column in SQL Server. I have done it in ACCESS but that method does not seem to work in SQL. Server.

0
Comment
Question by:sybe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 125 total points
ID: 9685605
You have to turn off the identity, insert the value and then turn on the identity again

set identity_insert on
insert into TABLE1 (id, name) VALUES(1, 'You')
set identity_insert off
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 9685620
use ..

SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }

 
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question