在sql中将列更改为标识(1,1)时出现问题 [英] Problem in altering a column to identity(1,1) in sql

查看:86
本文介绍了在sql中将列更改为标识(1,1)时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





我正在研究数据库合并概念,我有很多表列标识( 1,1)。现在我的问题是在合并旧数据库时,Id从数字开始,但不是从开始它的身份种子1开始。现在我在新数据库中创建了一个新表并复制粘贴记录,但它从1开始,所以我删除该表并从该表中移除身份(1,1)然后复制粘贴但粘贴后我再也无法设置身份通过设计或查询。

任何人都可以建议我如何在不更改表格中的数据的情况下将表数据从一个数据库传输到另一个数据库。





在此先感谢

Arun

Hi everyone ,


I am working on a database merging concept in this i am having many of the table column identity (1,1) . Now my problem is while merging the old DB the Id starts from number but not from beginning its then identity seeding by 1 . Now i have create a new table in new DB and copy pasting the record but it starts from 1 , so i drop that table and remover the identity (1,1) from that table then copy paste but after pasting i cant again set the identity by design or by query .
Can anyone suggest me how can i take table data from one DB to another DB without doing changes to data in table.


Thanks in Advance
Arun

推荐答案

您需要设置带有标识(1,1)的新列,当你用旧数据库中的数据填充它时暂时禁用自动生成,然后继续它应该工作...



看看< a href =http://msdn.microsoft.com/en-us/library/ms188059.aspx> SET IDENTITY_INSERT [ ^ ]让你入门
You need to set up the new column with identity(1,1), temporarily disable the auto-generate while you populate it with the data from the old DB, and then going forward it should work ...

Have a look at SET IDENTITY_INSERT[^] to get you started


这篇关于在sql中将列更改为标识(1,1)时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆