Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I disable and re-enable the IDENTITY property on a table column using T-SQL.

Posted on 2004-08-30
3
Medium Priority
?
917 Views
Last Modified: 2008-01-09
I would like to be able to disable and re-enable the identity property on a column using T-SQL. Here is my sample table:

CREATE TABLE [dbo].[tblTestIDENT] (
      [Col1] [int] IDENTITY (1, 1) NOT NULL ,
      [Col2] [varchar] (50) NULL
) ON [PRIMARY]
GO

What effect would this have if I have say 100 million records in the table?
0
Comment
Question by:DeMyu
[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
3 Comments
 
LVL 12

Expert Comment

by:ill
ID: 11931355
SET IDENTITY_INSERT [tblTestIDENT] ON
insert into tblTestIDENT (col1, col2) values (10, 'test1')
insert into tblTestIDENT (col1, col2) values (1001, 'test2')
SET IDENTITY_INSERT [tblTestIDENT] OFF
insert into tblTestIDENT (col2) values ( 'test3')
select * from [tblTestIDENT]
0
 

Author Comment

by:DeMyu
ID: 11931847
Thank you for your reply. This does not actually remove the identity property of the column in Enterprise Manager. Is there a way to do this in T-SQL such that when I go into EM I wouldn't see the property on the column. I have to do this on a table with about 70 million rows.

Thanks
0
 
LVL 12

Accepted Solution

by:
ill earned 1500 total points
ID: 11932089
i'm afraid, you need to recreate table. here is a useful link for you:
http://www.examnotes.net/archive79-2002-7-47264.html
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.

721 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