SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Create Statement


Create Statement

Author
Message
RichardDouglas
RichardDouglas
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1097 Visits: 707
Comments posted to this topic are about the item Create Statement

Hope this helps,
Rich



Koen Verbeeck
Koen Verbeeck
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27421 Visits: 13268
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...


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11020 Visits: 11994
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 MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
RichardDouglas
RichardDouglas
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1097 Visits: 707
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



crashdan
crashdan
SSC Eights!
SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)

Group: General Forum Members
Points: 848 Visits: 757
very useful question
sjimmo
sjimmo
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3756 Visits: 2904
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
Daniel Bowlin
Daniel Bowlin
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4104 Visits: 2629
Learned something new today, thanks.
Dave62
Dave62
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3245 Visits: 2777
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
Trey Staker
Trey Staker
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1272 Visits: 2788
Hugo Kornelis (10/18/2010)
[quote]

...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
SQLRNNR
SQLRNNR
SSC-Dedicated
SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)

Group: General Forum Members
Points: 32419 Visits: 18556
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

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search