Identity_column

  • Comments posted to this topic are about the item Identity_column

  • 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

  • True, but that won't cause no rows to be inserted, it''l stop the table creation in the first place...

  • 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.

  • 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).

  • 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.

  • 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.

  • 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

  • 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!:-D

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

    "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."

  • didn't notice the comma, but I realized the intent of the question.

  • Actually the answer is "NONE OF THE ABOVE". The answer (deemed correct) refers to IDENTITY INSERT set to ON. This query will run if IDENTITY INSERT is set to on. However, it is off. The actual error message refers to IDENTITY INSERT SET TO OFF. Minor verbiage change, but can make a big difference (several previous questions had details like this that made the difference between right and wrong so consistency should be maintained).

    CORRECTION: I just now saw the "not". The error message actually says "hen IDENTITY_INSERT is set to OFF" The "not" through me off.

    Cheers,

    Brian

  • sorry - posted about the comma without seeing all the other posts - dunno whats wrong with this browser of mine...

    MM



    select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);

  • Forum Etiquette: How to post Reporting Services problems
  • [/url]
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • [/url]
  • How to Post Performance Problems - by Gail Shaw
  • [/url]

  • yup

  • I too missed the extra comma but saw the intent of the question. Despite that, it is nice to have learned something about the extra comma in table creates.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • It was straight forward Q, and had a straight forward ans. 🙂



    [font="System"]Bhavesh Patel[/font]

    http://bhaveshgpatel.wordpress.com/
  • Viewing 15 posts - 1 through 14 (of 14 total)

    You must be logged in to reply to this topic. Login to reply