Solved

Force a value into an identity column

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

617 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