April 8, 2015 at 2:26 am
MyDoggieJessie (4/7/2015)
This assumes that you have a schema in the database named "tmp" otherwise it fails because the schema does not exist.
I agree, I supposed it was a trick: you notice that the name is valid and you do not note that schema is not.
April 8, 2015 at 2:51 am
It should have been possible to attempt an answer without just running the code. And, given the title of the question, it should have been clear that the "tmp" error was just an oversight and not really relevant.
April 8, 2015 at 3:05 am
Richard Warr (4/8/2015)
It should have been possible to attempt an answer without just running the code. And, given the title of the question, it should have been clear that the "tmp" error was just an oversight and not really relevant.
Only if you notice the question title! I always answer via the email, which doesn't include the title. And having read the question in the email, when I click the link my eyes go straight to the answers 🙂
April 8, 2015 at 4:09 am
This could have been a nice question about an interesting curiosity (though utterly useless, as nobody will ever use this in real life - right?).
Unfortunately, the mishap with the schema name ruins the question. I immediately saw that the correct answer depends on an assumption about the tmp schema, and while pondering which assumption to make noticed the question title. This still didn't convince me fully (there have in the past been questions with very misleading titles), but it did give me enough confidence to assume that the author has a tmp schema and has forgotten that not everyone has.
April 8, 2015 at 4:22 am
The table is not created. The question did not mention anything about the tmp schema existing.
This will fail with an error.
Msg 2760, Level 16, State 1, Line 1
The specified schema name "tmp" either does not exist or you do not have permission to use it.
April 8, 2015 at 4:48 am
MyDoggieJessie (4/7/2015)
This assumes that you have a schema in the database named "tmp" otherwise it fails because the schema does not exist.
As pointed out.
April 8, 2015 at 5:18 am
If only the code had been
declare @sql nvarchar(max)
set @sql = 'IF OBJECT_ID(''TempDB..[' + CHAR(31) + ']'') IS NOT NULL DROP TABLE TempDB..[' + CHAR(31) + ']' + CHAR(10) +
'create table tempdb..[' + char(31) + ']
(
id int
)'
EXECUTE sp_executesql @sql
April 8, 2015 at 5:24 am
Given the title of the question, I figured the tmp schema was an oversight. After changing the schema to dbo, I found the results simple enough. From there, try to do anything else with the table...interesting.
April 8, 2015 at 5:55 am
MyDoggieJessie (4/7/2015)
This assumes that you have a schema in the database named "tmp" otherwise it fails because the schema does not exist.
Agree
April 8, 2015 at 6:14 am
MyDoggieJessie (4/7/2015)
This assumes that you have a schema in the database named "tmp" otherwise it fails because the schema does not exist.
and again...+1
Another incorrect correct answer. TEST BEFORE POST. 😀
April 8, 2015 at 6:53 am
I got it wrong. So I tested it. It failed. Hmmmm.
April 8, 2015 at 6:53 am
MyDoggieJessie (4/7/2015)
This assumes that you have a schema in the database named "tmp" otherwise it fails because the schema does not exist.
Oh, that's why it failed. Thanks for the help.
April 8, 2015 at 6:54 am
Koen Verbeeck (4/8/2015)
Nice question, but a bit of an oversight on the tmp schema.
I totally agree.
April 8, 2015 at 6:58 am
free_mascot (4/8/2015)
Carlo Romagnano (4/8/2015)
MyDoggieJessie (4/7/2015)
This assumes that you have a schema in the database named "tmp" otherwise it fails because the schema does not exist.+1
Ahi, ahi, ahi, ahi, ahi, ahi!!!!!!!!!!
:w00t:
+1
+1
April 8, 2015 at 6:58 am
Sean of the Lynchmob (4/8/2015)
I got this when I ran it:Msg 2760, Level 16, State 1, Line 1
The specified schema name "tmp" either does not exist or you do not have permission to use it.
.....and no table created. So I have to disagree with the "correct" answer.....
+1
Viewing 15 posts - 16 through 30 (of 52 total)
You must be logged in to reply to this topic. Login to reply