Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««1234»»»

Identity Crisis: Attack of the Clone Expand / Collapse
Author
Message
Posted Wednesday, May 11, 2011 4:24 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, October 15, 2014 6:53 AM
Points: 2,165, Visits: 1,752
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.
Post #1106749
Posted Wednesday, May 11, 2011 5:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 10:02 AM
Points: 2, Visits: 95
Won't the create table statement fail due to the comma after the last column name?


Post #1106776
Posted Wednesday, May 11, 2011 7:13 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, October 9, 2014 8:27 AM
Points: 1,639, Visits: 1,984
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).
Post #1106884
Posted Wednesday, May 11, 2011 7:30 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:43 AM
Points: 1,939, Visits: 1,162
Excellent question and better explanation.

Malleswarareddy
I.T.Analyst
MCITP(70-451)
Post #1106908
Posted Wednesday, May 11, 2011 7:33 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 16, 2014 2:12 PM
Points: 2,278, Visits: 3,798
Really good question

Mohammed Moinudheen
Post #1106913
Posted Wednesday, May 11, 2011 8:06 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,228, Visits: 1,046
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.
Post #1106973
Posted Wednesday, May 11, 2011 8:07 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,228, Visits: 1,046
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.
Post #1106975
Posted Wednesday, May 11, 2011 8:28 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, June 3, 2014 8:57 AM
Points: 228, Visits: 236
good question and explanation.
Thanks.


Chris Umbaugh
Data Warehouse / Business Intelligence Consultant
twitter @ToledoSQL
Post #1107003
Posted Wednesday, May 11, 2011 8:49 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, September 30, 2014 7:42 AM
Points: 3,688, Visits: 72,435
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. :)

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
Post #1107024
Posted Wednesday, May 11, 2011 9:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, August 30, 2011 8:42 AM
Points: 4, Visits: 8
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.
Post #1107054
« Prev Topic | Next Topic »

Add to briefcase ««1234»»»

Permissions Expand / Collapse