Solved

Force a value into an identity column

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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.

920 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

12 Experts available now in Live!

Get 1:1 Help Now