|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 9:41 AM
Points: 1,608,
Visits: 1,098
|
|
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.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, April 30, 2013 2:33 PM
Points: 1,
Visits: 69
|
|
Won't the create table statement fail due to the comma after the last column name?
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 7:44 AM
Points: 1,555,
Visits: 1,925
|
|
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).
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 11:21 AM
Points: 1,848,
Visits: 982
|
|
Excellent question and better explanation.
Malleswarareddy I.T.Analyst MCITP(70-451)
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 3:34 PM
Points: 2,170,
Visits: 3,582
|
|
Really good question
Mohammed Moinudheen
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232,
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.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232,
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.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, September 24, 2012 10:53 AM
Points: 207,
Visits: 216
|
|
good question and explanation. Thanks.
Chris Umbaugh Data Warehouse / Business Intelligence Consultant twitter @chrisumbaugh
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 11:34 AM
Points: 3,229,
Visits: 64,267
|
|
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
|
|
|
|
|
Forum 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.
|
|
|
|