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 12»»

Identity_column Expand / Collapse
Author
Message
Posted Thursday, July 16, 2009 9:28 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, October 3, 2012 5:59 AM
Points: 226, Visits: 109
Comments posted to this topic are about the item Identity_column
Post #754586
Posted Friday, July 17, 2009 3:36 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, April 25, 2014 3:49 AM
Points: 174, Visits: 74
Actually, won't the comma after the lname column cause a syntax error? So, of those answers, "no rows will be inserted" is technically the most correct answer.

Jim
Post #754695
Posted Friday, July 17, 2009 4:00 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, October 15, 2014 7:54 AM
Points: 999, Visits: 871
True, but that won't cause no rows to be inserted, it''l stop the table creation in the first place...


Post #754699
Posted Friday, July 17, 2009 4:55 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, October 27, 2014 7:45 AM
Points: 1,425, Visits: 1,589
The syntax is forgiving about the extra comma. I tried it and was able to create the table per the script.

Seems this has come up in the course of my typing Create statements -- add the comma by default then decide no more columns are needed and the table still creates. Another example is when generating Create Table statements.
Post #754714
Posted Friday, July 17, 2009 5:36 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, May 23, 2014 12:39 PM
Points: 14, Visits: 29
I'm sorry but you're wrong. This query as written will fail for syntax reasons. The comma after lname varchar(20), requires that another field be listed next, but one is not listed, therefore it will fail (which is answer A).
Post #754731
Posted Friday, July 17, 2009 5:45 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 24, 2013 9:59 PM
Points: 1,354, Visits: 1,299
Although I got the question right (I did not notice the extra comma), I agree this is a bad question. When you get the error message, no records get inserted into the table. Both the first and last option was correct.

I knew either of them could have been the correct answer but the last one was more specific to the problem on why no records would have been inserted. Still, I believe anyone who selects the first answer should also get it right.
Post #754739
Posted Friday, July 17, 2009 6:07 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, October 27, 2014 7:45 AM
Points: 1,425, Visits: 1,589
Which version is giving you an error message?

It executes fine in 2008. I tried because my recollection was that the comma does not cause a problem and hasn't for several versions.


create table employe
(
id_num int identity(1,1),
fname varchar(20),
lname varchar(20),
)

Command(s) completed successfully.

Post #754751
Posted Friday, July 17, 2009 6:07 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, April 25, 2014 3:49 AM
Points: 174, Visits: 74
I stand corrected. I just tried this query, as written, on both SQLServer 2000 and 2005 and the table DOES get created, even in spite of the extra comma.

Jim
Post #754752
Posted Friday, July 17, 2009 6:45 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, October 20, 2014 11:55 AM
Points: 1,330, Visits: 19,306
I'm with you guys, I assumed that the comma would cause it to error before the table even got created.

So, despite the ambiguous choices, learned something new!


---------------------------------------------------------
How best to post your question
How to post performance problems
Tally Table:What it is and how it replaces a loop

"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
Post #754776
Posted Friday, July 17, 2009 10:22 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 10:12 AM
Points: 31,210, Visits: 15,651
didn't notice the comma, but I realized the intent of the question.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #754980
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse