Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Identity Crisis: Attack of the Clone


Identity Crisis: Attack of the Clone

Author
Message
Richard Warr
Richard Warr
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2578 Visits: 1983
A question that enables most people to get the correct answer after some careful thought is by no means "too simple". Especially as over 1/3 of respondants have got it wrong.

For me this was close to a "Goldilocks" question. For some it's too hard, for others too soft, but for many, it's just right.

_____________________________________________________________________
MCSA SQL Server 2012
sread
sread
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 126
Won't the create table statement fail due to the comma after the last column name?



chrisfradenburg
chrisfradenburg
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1732 Visits: 2057
sread (5/11/2011)
Won't the create table statement fail due to the comma after the last column name?


I just tried it on my machine and it ran fine. I do remember this being discussed someplace as being legit and someone mentioning that they have made a practice of doing to make it easier to add columns (one less thing to forget).
malleswarareddy_m
malleswarareddy_m
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2011 Visits: 1189
Excellent question and better explanation.

Malleswarareddy
I.T.Analyst
MCITP(70-451)
M&M
M&M
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2595 Visits: 3898
Really good question

M&M
SanDroid
SanDroid
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1414 Visits: 1046
Good easy question, but I do not agree with the answers explination.

A unique constraint is what a table needs to garuntee an column does not repeat values.
Making a column part of a Primary Key value does create a constraint for Unique values.
That is the effect not the cause.

If both columns in the table are selected as Primary Key, then you could still insert duplicates into the Unique_Id column.

Make sure your Identity columns have there own Unique Index and/or value constraint and you don't have to worry about dupes.
SanDroid
SanDroid
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1414 Visits: 1046
Richard Warr (5/11/2011)
A question that enables most people to get the correct answer after some careful thought is by no means "too simple". Especially as over 1/3 of respondants have got it wrong.

For me this was close to a "Goldilocks" question. For some it's too hard, for others too soft, but for many, it's just right.


LOL... Richard I could not agree more. Hehe
Chris Umbaugh
Chris Umbaugh
SSC Veteran
SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)

Group: General Forum Members
Points: 234 Visits: 241
good question and explanation.
Thanks.

Chris Umbaugh
Data Warehouse / Business Intelligence Consultant
twitter @ToledoSQL
mtassin
mtassin
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4101 Visits: 72512
Richard Warr (5/11/2011)
A question that enables most people to get the correct answer after some careful thought is by no means "too simple". Especially as over 1/3 of respondants have got it wrong.

For me this was close to a "Goldilocks" question. For some it's too hard, for others too soft, but for many, it's just right.



I got it wrong... only because of two things.

1. I've spent the past several weeks going through hundreds of tables with structures like

CREATE TABLE staff(
STAFFID INT IDENTITY(1,1) NOT NULL,
STAFFNAME VARCHAR(100))

CREATE UNIQUE CLUSTERED INDEX UCI_PK ON staff(STAFFID)



At that point, just call the bloody thing a primary key.

So I see INT IDENTITY(1,1) and these days I assume PRIMARY KEY is stuck on the end of it.

Then I misread the answer that said it was a violation of the IDENTITY constraint. Which I know isn't a constraint... I was just rushed because I have a meeting in 10 min. Smile

Oops.



--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
steven.chester
steven.chester
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 10
What's funny is that I couldn't pick my first answer: a syntax error. There's a superfluous comma in the DDL for the table.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search