在SQL Server IGNORE_DUP_KEY选项 [英] IGNORE_DUP_KEY option in SQL Server

查看:3055
本文介绍了在SQL Server IGNORE_DUP_KEY选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了MSDN和谷歌在相当长的一段搜索,但看起来像IGNORE_DUP_KEY选项的说明是非常有限的。

I did quite some search in MSDN and Google, but looks like the description for IGNORE_DUP_KEY option is very limited.

我的困惑,

  1. 是IGNORE_DUP_KEY选项一栏的选项?为表?一对夫妇列?对于指数(使指数唯一的)?

  1. Is IGNORE_DUP_KEY option an option for a column? for a table? for a couple of columns? for an index (making index unique)?

如果设置IGNORE_DUP_KEY为是,当插入一批记录(使用大容量插入在WriteToServer ADO.Net功能)有重复键(例如,我插入它已经在数据库中存在的一些值),SQL Server将不抛出一个错误。批处理作业将成功完成,但重复的行不会被插入。所有其它行会被插入和SQL Server把它当作工作的成功。我的理解是否正确?

If set IGNORE_DUP_KEY to Yes, when insert a batch of records (using bulk insert WriteToServer ADO.Net function) with duplicate keys (for example, I insert some values which already exist in database), SQL Server will not throw an error. The batch job will be completed successfully but the duplicated rows will not be inserted. All other rows will be inserted and SQL Server treat it as a job success. Is my understanding correct?

在此先感谢, 乔治

推荐答案

IGNORE_DUP_KEY是CREATE INDEX的一个选项,只影响多行插入:

IGNORE_DUP_KEY is an option of CREATE INDEX and only affects inserts of multiple rows:

IGNORE_DUP_KEY = ON

IGNORE_DUP_KEY = ON

  • 在所有的唯一行得到插入,则会发出警告,并重复的行不插入

IGNORE_DUP_KEY = OFF

IGNORE_DUP_KEY = OFF

  • 在发出一个错误,没有行被插入

这篇关于在SQL Server IGNORE_DUP_KEY选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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