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.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: 1325 Visits: 707
Comments posted to this topic are about the item Create Statement

Hope this helps,
Rich



Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: General Forum Members
Points: 62446 Visits: 13298
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
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18805 Visits: 12426
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.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: 1325 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
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1022 Visits: 757
very useful question
sjimmo
sjimmo
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4802 Visits: 2907
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
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

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

Group: General Forum Members
Points: 3570 Visits: 2833
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
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1620 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 Guru
SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)

Group: General Forum Members
Points: 66601 Visits: 18570
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