Temp Table Names

  • peter.row (4/10/2015)


    The script in the answer fails because of the following:

    select @a, @b-2, @C

    As @C is not declared (nor is it used elsewhere in the script).

    It has been corrected to @cmd

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • SQLRNNR (4/10/2015)


    Great explanation. Because BOL said so. :hehe::hehe:

    :-D:-D

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Another explanation has been given in a session of the SQL Server 2012 Days in Paris by a person of the SQL Server Support. In a slide , there was a partial copy of the BOL

    If more than one temporary table is created inside a single stored procedure or batch, they must have different names.

    If a local temporary table is created in a stored procedure or application that can be executed at the same time by several users, the Database Engine must be able to distinguish the tables created by the different users. The Database Engine does this by internally appending a numeric suffix to each local temporary table name. The full name of a temporary table as stored in the sysobjects table in tempdb is made up of the table name specified in the CREATE TABLE statement and the system-generated numeric suffix. To allow for the suffix, table_name specified for a local temporary name cannot exceed 116 characters.

    I think it is an easy reason to understand the limit of the length of 116 characters for temp tables versus the 128 length for the 'normal' permanent tables .

  • Nice question, although I had a déjà vu feeling about this one.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • John Mitchell-245523 (4/10/2015)


    sknox (4/10/2015)


    John Mitchell-245523 (4/10/2015)


    Richard Warr (4/10/2015)


    Where it says "116 characters or less" it means "116 characters or fewer" 😉

    I would argue that either is correct. If you interpret "116 characters" as a length, then "less" is OK. If you interpret it as a number of characters, it has to be "fewer". It's similar to the age-old debate about the "12 items or less" queue at the supermarket. If you see 12 items as an amount of shopping, rather than a number of items, it's right to say "less".

    Anyway, got the question horribly wrong, and thus learnt something - thanks Steve!

    John

    Not to derail this thread, but the distinction between "less" and "fewer" is about discrete vs continuous units, not about length vs quantity.

    The day you can create a 5 and a half character string, and purchase 2.714 items from the store, I'll agree with you. 😛

    It's a question of style, and I don't think either is wrong. I'm not saying that it's correct in all cases to use "less" and "fewer" interchangeably, but I'm arguing that it is here. See this blog[/url] from the Oxford Dictionaries website.

    John

    It's not just about discrete vs continuous units - although that's a good rule of thumb - populations are measured in discrete units but the population of Wales is less than the population of England, because fewer people live there. Also, it's not always 'I before E except after C' - are we straying a little off topic?

  • Thanks for the question.

  • Richard Warr (4/10/2015)


    There's a good article at Simple Talk[/url] which mentions the limit and the reason.

    Where it says "116 characters or less" it means "116 characters or fewer" 😉

    Technically you are correct. But I find that "less" is used more and more often, perhaps to the point that it may one day become "correct" in our ever evolving language.

  • Richard Warr (4/10/2015)


    There's a good article at Simple Talk[/url] which mentions the limit and the reason.

    Where it says "116 characters or less" it means "116 characters or fewer" 😉

    It's rather easy to choose the wrong one of "fewer" and "less" but it's rather easy too to fail to notcethat either could be correct in a particular sentence. I think Phil has committed no error, while you've committed the second one I mentioned. The verb "is" in that sentence doesn't force the choice of one rather than the other. The following are all correct:

    The name consists of 128 characters or fewer.

    The name is comprised of 128 characters or fewer.

    The name's length is 128 characters or less.

    The name is 128 characters long or less.

    "Is" (on it's own) instead of "consists of" or "is comprised of" or "is ... long" or "'s length is" doesn't force one to pick one instead of the other - it leaves it wide open whether one is treating "character" as a unit of length or an individual object in a collection, and it's that choice which determines whether "less" or "fewer" is appropriate.

    I've been heavily involved in data communications and learnt a fair bit of signal theory as a result so I am used to regarding things like "characters" and "bits" as units of length rather than as elements of a collection, so "less" seems appropriate; but other aspects of computing and of data communications have made me think of characters and bits as things I count so that "fewer" seems appropriate. So I'm used to cases where either word can be used, according to how one is looking at something.

    Tom

  • + 1 Tom.

    I am thinking that it is only a discussion about the meaning of words which is really far from the topic of the original question.

    I think that you have clarified the notion of length , count of characters at least for me ( the English language is not my mother tongue ).

    So thanks , Tom.

  • patricklambin (4/18/2015)


    + 1 Tom.

    I am thinking that it is only a discussion about the meaning of words which is really far from the topic of the original question.

    I think that you have clarified the notion of length , count of characters at least for me ( the English language is not my mother tongue ).

    So thanks , Tom.

    There was an original question???

  • +1

Viewing 11 posts - 16 through 25 (of 25 total)

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