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


Creating Tables


Creating Tables

Author
Message
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: 3243 Visits: 2777
Comments posted to this topic are about the item Creating Tables
bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)SSCertifiable (7.8K reputation)

Group: General Forum Members
Points: 7819 Visits: 25280
Nice question to start the week ... reminded me of the basics once again.

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
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: 32286 Visits: 18552
Thanks for the question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

kapil_kk
kapil_kk
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3075 Visits: 2766
Good basic question to start the week..... :-)

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
binod.soft
binod.soft
SSC-Addicted
SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)SSC-Addicted (406 reputation)

Group: General Forum Members
Points: 406 Visits: 165
The Statement has three GO syntax which indicates three Batches. Each Go used shows an end of the Batch. I have shown below each of the GO with their end of batches comments.
But As per your question the statement should be executed in a single Batch in which case One has to remove all the GO syntax to execute the whole Query in a single Batch. And hence "Option 2 : All statement should fail" must be the right answer.
The Error must be :--
Msg 2714, Level 16, State 1, Line 18
There is already an object named '#TempQoD' in the database.

Where as if you execute the whole statement with all GO syntax as it is .. In that case the Answer must be option 3.

-- Statement 1
Create Table #TempQoD
(
RowId Integer
, Question varChar(max)
, Answer varChar(max)
, PublishDate Date
);

Go--End of first batch

-- Statement 2
Select
1 As [RowId]
, 'True or False: The HAVING clause is the 4th phase of logical query processing?' As [Question]
, 'True: 1-FROM, 2-WHERE, 3-GROUP BY, 4-HAVING, 5-SELECT, 6-ORDER BY.' As [Answer]
, '15 Jan 2013' As [PublishDate]
Into
#TempQoD;

Go--End of 2nd Batch

-- Statement 3
Select * From #TempQoD;


Drop Table #TempQoD;
GO--End Of third batch
demonfox
demonfox
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1517 Visits: 1192
binod.soft (2/10/2013)
The Statement has three GO syntax which indicates three Batches. Each Go used shows an end of the Batch. I have shown below each of the GO with their end of batches comments.
But As per your question the statement should be executed in a single Batch in which case One has to remove all the GO syntax to execute the whole Query in a single Batch. And hence "Option 2 : All statement should fail" must be the right answer.
The Error must be :--
Msg 2714, Level 16, State 1, Line 18
There is already an object named '#TempQoD' in the database.

Where as if you execute the whole statement with all GO syntax as it is .. In that case the Answer must be option 3.

-- Statement 1
Create Table #TempQoD
(
RowId Integer
, Question varChar(max)
, Answer varChar(max)
, PublishDate Date
);

Go--End of first batch

-- Statement 2
Select
1 As [RowId]
, 'True or False: The HAVING clause is the 4th phase of logical query processing?' As [Question]
, 'True: 1-FROM, 2-WHERE, 3-GROUP BY, 4-HAVING, 5-SELECT, 6-ORDER BY.' As [Answer]
, '15 Jan 2013' As [PublishDate]
Into
#TempQoD;

Go--End of 2nd Batch

-- Statement 3
Select * From #TempQoD;


Drop Table #TempQoD;
GO--End Of third batch


Well, Let's not lost the question in the wordings; what's the point of three Go Statements , if the statement meant to remove them and then execute ..
as it said
What will the outcome be after running all the following statements as 1 batch?


All the following statements, means Including Go ..

nice and simple , basics refreshed with a good question ...
thanks for the question

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
manik_anu
manik_anu
SSC-Addicted
SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)

Group: General Forum Members
Points: 446 Visits: 312
nice question... starting with basic morning....:-)

Manik
You cannot get to the top by sitting on your bottom.
vk-kirov
vk-kirov
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3702 Visits: 4408
binod.soft (2/10/2013)

remove all the GO syntax to execute the whole Query in a single Batch

I agree with you. The wording of the question is totally misleading.

demonfox (2/10/2013)

All the following statements, means Including Go ..

How about this:
http://msdn.microsoft.com/en-us/library/ms188037.aspx
GO (Transact-SQL)
Remarks
GO is not a Transact-SQL statement

So I read the question as following:
1) Do something to make the following statements to belong to one batch (ie, remove all GOs);
2) Run the resulting batch;
3) What will the outcome be?
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: 27343 Visits: 13268
For me the question was more about the fact you can use Integer instead of int. Didn't know that :-D
The question cleverly had no color coding on the word Integer, so I assumed SSMS didn't recognize it. But actually it does when you copy paste the code into SSMS.

Interesting...


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
demonfox
demonfox
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1517 Visits: 1192
vk-kirov (2/10/2013)

GO (Transact-SQL)
Remarks
GO is not a Transact-SQL statement

So I read the question as following:
1) Do something to make the following statements to belong to one batch (ie, remove all GOs);
2) Run the resulting batch;
3) What will the outcome be?


As you said all the wordings ; besides when it says statements then I understood it as the statements written to separate three statements ; and you understood that as T-Sql Statements BigGrin

For me the question was more about the fact you can use Integer instead of int. Didn't know that


+1
I missed that w00t BigGrin

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
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