Create Statement

  • Comments posted to this topic are about the item Create Statement

    Hope this helps,
    Rich

    [p]
    [/p]

  • Very nice question, definately learned something today.

    Got it wrong, because the BOL page about CREATE SCHEMA didn't mention anything about batches.

    Ah well...

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

  • da-zero (10/18/2010)


    Very nice question, definately learned something today.

    Got it wrong, because the BOL page about CREATE SCHEMA didn't mention anything about batches.

    Ah well...

    It doesn't really stand out, but the information is there:

    This statement must be executed as a separate batch.

    (See http://msdn.microsoft.com/en-us/library/ms189462.aspx)

    Nice question, Richard - I almost fell for it; I was saved by the feeling of "it can't be that simple, let's look a bit further". (That being said, I always forget which statements must run in seperate batches, so I very often get errors because of that).

    Oh, one final remark - if I should copy and paste your script in SSMS and execute it, I would actually get a different error: "Could not locate entry in sysdatabases for database 'TempDB'. No entry found with that name. Make sure that the name is entered correctly."

    On a server with a case sensitive collation, database names are case sensitive as well. You should use all lower case for the system databases tempdb, system, model, and msdb.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Da-Zero, glad you found the question useful!

    Hugo Kornelis (10/18/2010)

    Oh, one final remark - if I should copy and paste your script in SSMS and execute it, I would actually get a different error: "Could not locate entry in sysdatabases for database 'TempDB'. No entry found with that name. Make sure that the name is entered correctly."

    On a server with a case sensitive collation, database names are case sensitive as well. You should use all lower case for the system databases tempdb, system, model, and msdb.

    That's a great point Hugo, thanks. I'll check my code for better portability next time.

    Hope this helps,
    Rich

    [p]
    [/p]

  • very useful question

  • Great question. Had to reread to catch the problem because I knew that nobody would intentionally create user objects in tempdb.

    Hugo brings up a good point as well about the collation settings applying to the database names. I do not have that collation set so I did not get the same error when running (after answering:-))

    Steve Jimmo
    Sr DBA
    “If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan

  • Learned something new today, thanks.

  • Thanks for the question. Very instructive topic and discussion.

    I'm a little confused by the wording of the question though.

    "What do you anticipate the outcome of the following T-SQL code to be?"

    How could this be answered incorrectly? If you mark the answer you did in fact anticipate, shouldn't it be correct? 😉

    Dave

  • Hugo Kornelis (10/18/2010)


    ...Oh, one final remark - if I should copy and paste your script in SSMS and execute it, I would actually get a different error: "Could not locate entry in sysdatabases for database 'TempDB'. No entry found with that name. Make sure that the name is entered correctly."

    On a server with a case sensitive collation, database names are case sensitive as well. You should use all lower case for the system databases tempdb, system, model, and msdb.

    Thanks Hugo, This is something that I didn't know.

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

  • Thanks for the nice question.

    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

  • Great question.

    Rob Schripsema
    Propack, Inc.

Viewing 11 posts - 1 through 10 (of 10 total)

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