|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:48 AM
Points: 5,235,
Visits: 7,037
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 6:41 AM
Points: 2,440,
Visits: 713
|
|
The negative ("This option may NOT be specified...") - urrgh... semantics. Does it mean that it can be but that you shouldn't because it doesn't make sense but it is allowed anyway?
To my surprise, the syntax for CREATE TABLE and ALTER TABLE does allow you to specify the IGNORE_DUP_KEY option for PRIMARY KEY and UNIQUE constraints.
Just the same Hugo - good question. It looks closely at an issue that is odd at best. Thanks
Jamie
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:48 AM
Points: 5,235,
Visits: 7,037
|
|
Jamie Longstreet (11/5/2008) The negative ("This option may NOT be specified...") - urrgh... semantics. Does it mean that it can be but that you shouldn't because it doesn't make sense but it is allowed anyway?[/hr]
Hi Jamie,
You're right. Looking back at the question, I think it would have been better to phrase it as "... may be specified ..." (and invert the correctness mark of this answer, of course), or possibly as "... can't be specified ...". To clarify, my intention was solely to test for allowed syntax, not for good or bad practice - though I personally consider this option to be bad practice in its entirety ;)
Just the same Hugo - good question. It looks closely at an issue that is odd at best. Thanks
You're welcome, and thanks for the kind words. :D
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 15, 2013 2:43 PM
Points: 3,924,
Visits: 1,554
|
|
CREATE INDEX NotAllowed ON Dest (Value) WITH(IGNORE_DUP_KEY = ON); go
Msg 1916, Level 16, State 4, Line 1 CREATE INDEX options nonunique and ignore_dup_key are mutually exclusive.
ignore_dup_key should come with Unique key.
CREATE UNIQUE INDEX NotAllowed
Good question though. I used this option mostly while merging data from different server.tables into my reporting server, where it won't insert duplicate data.
SQL DBA.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 15, 2013 2:43 PM
Points: 3,924,
Visits: 1,554
|
|
Got answer right by fluke. Wasn't sure if I should select his option or not. Though I thought this should be in.
-- This option may not be specified for the index that supports the PRIMARY KEY.
SQL DBA.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:48 AM
Points: 5,235,
Visits: 7,037
|
|
SanjayAttray (11/5/2008) CREATE INDEX NotAllowed ON Dest (Value) WITH(IGNORE_DUP_KEY = ON); go
Msg 1916, Level 16, State 4, Line 1 CREATE INDEX options nonunique and ignore_dup_key are mutually exclusive.
ignore_dup_key should come with Unique key.
CREATE UNIQUE INDEX NotAllowed
Hi Sanjay,
Maybe I am misunderstanding you - isn't this exactly as I say in the answer explanation?
Good question though. I used this option mostly while merging data from different server.tables into my reporting server, where it won't insert duplicate data.
Thanks for the kind words. :)
Situations such as what you describe, also known as staging tables, are indeed about the only place where I would consider using this option (though even in that case, I would probably prefer a DISTINCT and/or NOT EXISTS to prevent duplicates - unless that would cause too many performance problems).
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Yesterday @ 6:03 AM
Points: 4,787,
Visits: 1,335
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:48 AM
Points: 5,235,
Visits: 7,037
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 11:48 AM
Points: 2,015,
Visits: 2,843
|
|
Good question. Not because of the question itself but because of one of the answers. I went on a tangent to relearn the goals of ACID. That reminded me of a design issue I'm currently working on. It's amazing how a question like this will have relevance when you least expect it.
Very timely.
Thanks.
:)
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:48 AM
Points: 5,235,
Visits: 7,037
|
|
skjoldtc (11/6/2008) Good question. Not because of the question itself but because of one of the answers. I went on a tangent to relearn the goals of ACID. That reminded me of a design issue I'm currently working on. It's amazing how a question like this will have relevance when you least expect it.
Very timely.
Thanks.
:)
You're most welcome. ;) (Though in all honesty, I can't take any credit for the timing :D)
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|