Solved

Force a value into an identity column

Posted on 2003-11-05
2
740 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
2 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 125 total points
Comment Utility
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
Comment Utility
use ..

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

 
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now