October 16, 2010 at 12:56 pm
Comments posted to this topic are about the item Create Statement
October 18, 2010 at 2:20 am
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
October 18, 2010 at 2:51 am
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.
October 18, 2010 at 3:11 am
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.
October 18, 2010 at 6:26 am
very useful question
October 18, 2010 at 6:27 am
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
October 18, 2010 at 6:47 am
Learned something new today, thanks.
October 18, 2010 at 7:12 am
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
October 18, 2010 at 9:29 am
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
October 18, 2010 at 10:15 am
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
October 18, 2010 at 4:13 pm
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