Solved

Force a value into an identity column

Posted on 2003-11-05
2
751 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

739 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