Solved

Using TSQL to make a PK column identity specification

Posted on 2006-06-24
4
478 Views
Last Modified: 2008-02-26
How do I, using TSQL, make a column in a table named IDNumber (which is a primary key) identity specification?  And how do I make it, if it is identity specification, not identity specification?
0
Comment
Question by:stev0931
  • 2
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16975700
you cannot change a column to change the identity specification, you have to drop and recreate the column to change it.
another way is to recreate the column entirely.

you should not need to change the specification of identity in prod application, can you explain why you want to do this?
 
0
 

Author Comment

by:stev0931
ID: 16976086
I want to move data from 4 tables from one database to another.  I tried doing an Export Data, but it failed since the fields are identity specification
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 16976409
>but it failed since the fields are identity specification

with DTS, there is a option to allow to insert into a identity field.
in TSQL, the command would be

SET IDENTITY_INSERT ON (tablename)

INSERT ....

SET IDENTITY_INSERT OFF (tablename)
0
 

Author Comment

by:stev0931
ID: 16976712
Thanks!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

746 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

10 Experts available now in Live!

Get 1:1 Help Now