Are the posted questions getting worse?

  • Paul White NZ (8/12/2010)


    David Benoit (8/12/2010)


    Paul White NZ (8/12/2010)


    You can name constraints on # and ## temporary tables, but it is a pretty bad idea.

    I haven't had a need to do this (or even consider it yet) but wondering what makes it a "bad idea"? Thanks in advance for the knowledge share.

    A constraint name is scoped to the database, but # and ## tables are all created in the same database: tempdb.

    Because # and ## tables can be created independently on more than one connection, this can lead to a name collision.

    Try running the following code from two separate connections to the same server:

    CREATE TABLE #temp (a INTEGER NOT NULL CONSTRAINT pk_temp PRIMARY KEY);

    You'll get an error on the second connection:

    .Net SqlClient Data Provider: Msg 2714, Level 16, State 4, Line 1

    There is already an object named 'pk_temp' in the database.

    .Net SqlClient Data Provider: Msg 1750, Level 16, State 0, Line 1

    Could not create constraint. See previous errors.

    It could get even more confusing, if you like:

    IF OBJECT_ID('tempdb..#temp') IS NOT NULL

    DROP TABLE #temp

    CREATE TABLE #temp (a INTEGER NOT NULL PRIMARY KEY);

    INSERT INTO #temp VALUES (0);

    EXECUTE('SELECT * FROM #temp;

    CREATE TABLE #temp (b char(2) NOT NULL PRIMARY KEY);

    INSERT INTO #temp VALUES (''AA'');

    SELECT * FROM #temp;')

    Output:

    a

    -----------

    0

    b

    ----

    AA

    Nice, isn't it?

    -- Gianluca Sartori

  • Alvin Ramard (8/12/2010)


    CirquedeSQLeil (8/12/2010)


    In case any of you threadizens are available or interested

    Grant will be presenting to my UG tonight. You can start joining the livemeeting at 6PM PST.

    http://bit.ly/cdzP7k

    I'd love to join you online, but we'll be wrapping up our meeting when yours starts.

    Are you recording the presentation?


    P.S. If you're in the Memphis area tonight, come join us for:

    Dan Evans - Creating an EPM Environment Using Microsoft SQL Server 2008 R2 and SharePoint 2010

    Check our humble website for more details: http://Mem-PASS.org

    We plan on recording it. Grant should be starting his preso after 6:30 if it makes any diff.

    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

  • CirquedeSQLeil (8/12/2010)


    Alvin Ramard (8/12/2010)


    CirquedeSQLeil (8/12/2010)


    In case any of you threadizens are available or interested

    Grant will be presenting to my UG tonight. You can start joining the livemeeting at 6PM PST.

    http://bit.ly/cdzP7k

    I'd love to join you online, but we'll be wrapping up our meeting when yours starts.

    Are you recording the presentation?


    P.S. If you're in the Memphis area tonight, come join us for:

    Dan Evans - Creating an EPM Environment Using Microsoft SQL Server 2008 R2 and SharePoint 2010

    Check our humble website for more details: http://Mem-PASS.org

    We plan on recording it. Grant should be starting his preso after 6:30 if it makes any diff.

    The earliest I could tune in would be 9:00 Central, or 7 Pacific. 😉

    Guess I'll have to go looking for your recording later.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Gianluca Sartori (8/12/2010)


    It could get even more confusing, if you like:

    /snip/

    Nice, isn't it?

    Very nice. Hadn't seen that one before. There's so much weirdness around temporary tables...

    USE tempdb;

    GO

    CREATE SCHEMA #SSC;

    GO

    CREATE TYPE #SSC FROM INT NOT NULL;

    GO

    CREATE TABLE #SSC (INT #SSC NULL);

    GO

    ALTER TABLE #SSC.#SSC.#SSC

    ADD #SSC #SSC;

    GO

    INSERT #SSC.#SSC.#SSC.#SSC

    (#SSC.#SSC.#SSC.#SSC.#SSC)

    SELECT #SSC = #SSC.#SSC

    FROM #SSC.#SSC.#SSC.#SSC AS #SSC;

    GO

    ALTER SCHEMA #SSC TRANSFER #SSC.#SSC.#SSC;

    GO

    SELECT #SSC = OBJECT_SCHEMA_NAME(OBJECT_ID(N'OBJECT_ID.#SSC', N'U'), DB_ID(N'tempdb'));

    GO

    DROP TABLE #SSC.#SSC.#SSC

    DROP TYPE #SSC;

    DROP SCHEMA #SSC;

    I sometimes wonder if table variables weren't introduced as a long-term replacement for temporary tables.

    Paul

  • Paul White NZ (8/12/2010)


    Gianluca Sartori (8/12/2010)


    It could get even more confusing, if you like:

    /snip/

    Nice, isn't it?

    Very nice. Hadn't seen that one before. There's so much weirdness around temporary tables...

    USE tempdb;

    GO

    CREATE SCHEMA #SSC;

    GO

    CREATE TYPE #SSC FROM INT NOT NULL;

    GO

    CREATE TABLE #SSC (INT #SSC NULL);

    GO

    ALTER TABLE #SSC.#SSC.#SSC

    ADD #SSC #SSC;

    GO

    INSERT #SSC.#SSC.#SSC.#SSC

    (#SSC.#SSC.#SSC.#SSC.#SSC)

    SELECT #SSC = #SSC.#SSC

    FROM #SSC.#SSC.#SSC.#SSC AS #SSC;

    GO

    ALTER SCHEMA #SSC TRANSFER #SSC.#SSC.#SSC;

    GO

    SELECT #SSC = OBJECT_SCHEMA_NAME(OBJECT_ID(N'OBJECT_ID.#SSC', N'U'), DB_ID(N'tempdb'));

    GO

    DROP TABLE #SSC.#SSC.#SSC

    DROP TYPE #SSC;

    DROP SCHEMA #SSC;

    I sometimes wonder if table variables weren't introduced as a long-term replacement for temporary tables.

    Paul

    So who is going to write up the article on all of this temp table discussion from the water cooler?

    I think it would be great to have an article or blog post containing these things as a reference point.

    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

  • CirquedeSQLeil (8/12/2010)


    So who is going to write up the article on all of this temp table discussion from the water cooler? I think it would be great to have an article or blog post containing these things as a reference point.

    Well, Wayne Sheffield covered most of it in his previous SSC publication. The other stuff isn't secret or anything so I guess anyone with the time or inclination could write/blog about it. I have a huge queue of topics as it is, and a head cold, so it is unlikely to be me.

  • Alvin Ramard (8/12/2010)


    CirquedeSQLeil (8/12/2010)


    In case any of you threadizens are available or interested

    Grant will be presenting to my UG tonight. You can start joining the livemeeting at 6PM PST.

    http://bit.ly/cdzP7k

    I'd love to join you online, but we'll be wrapping up our meeting when yours starts.

    Are you recording the presentation?


    P.S. If you're in the Memphis area tonight, come join us for:

    Dan Evans - Creating an EPM Environment Using Microsoft SQL Server 2008 R2 and SharePoint 2010

    Check our humble website for more details: http://Mem-PASS.org

    Make your meetin' a double-wide, and broadcast Grant for the whole group!

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

  • Paul White NZ (8/12/2010)


    CirquedeSQLeil (8/12/2010)


    So who is going to write up the article on all of this temp table discussion from the water cooler? I think it would be great to have an article or blog post containing these things as a reference point.

    Well, Wayne Sheffield covered most of it in his previous SSC publication. The other stuff isn't secret or anything so I guess anyone with the time or inclination could write/blog about it. I have a huge queue of topics as it is, and a head cold, so it is unlikely to be me.

    I know it was all my fault, but unfortunately I got-got-got-got no time. Wish I did.

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

  • Paul White NZ (8/12/2010)


    CirquedeSQLeil (8/12/2010)


    So who is going to write up the article on all of this temp table discussion from the water cooler? I think it would be great to have an article or blog post containing these things as a reference point.

    Well, Wayne Sheffield covered most of it in his previous SSC publication. The other stuff isn't secret or anything so I guess anyone with the time or inclination could write/blog about it. I have a huge queue of topics as it is, and a head cold, so it is unlikely to be me.

    Interesting idea indeed!!!!



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Here's a funny - timely career advice....http://www.sqlservercentral.com/Forums/Topic599801-373-3.aspx#bm968376

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

  • jcrawf02 (8/12/2010)


    Here's a funny - timely career advice....http://www.sqlservercentral.com/Forums/Topic599801-373-3.aspx#bm968376

    Lynn's reply to Celko cracked me up to the point that people around me are looking at me strangely. :hehe:

    ---------------------------------------------------------------------
    Use Full Links:
    KB Article from Microsoft on how to ask a question on a Forum

  • I was swamped with work for 2 weeks then took a week vacations. I just caught up with the thread, I think during that time spread on this thread there were atleast 3 separate long conversations about Joe's odious online personality. My 2 cents, I'm with Jason in that I usually see that he has posted and skip what he posted and like Lynn I'd never read or buy any of his books. If anything his comments over time have made me want less ISO standards.

    ---------------------------------------------------------------------
    Use Full Links:
    KB Article from Microsoft on how to ask a question on a Forum

  • Should I have stopped at the value below?

    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

  • CirquedeSQLeil (8/12/2010)


    Should I have stopped at the value below?

    That's one hell of a beast!



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • P.S. If you're in the Memphis area tonight, come join us for:

    Dan Evans - Creating an EPM Environment Using Microsoft SQL Server 2008 R2 and SharePoint 2010

    Check our humble website for more details: http://Mem-PASS.org

    I don't suppose I got lucky and this was recorded?

    Exactly where we are headed, working on building a dev environment to play with.

    Greg E

Viewing 15 posts - 17,431 through 17,445 (of 66,712 total)

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