Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

Creating Tables Expand / Collapse
Author
Message
Posted Saturday, February 9, 2013 3:09 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, November 21, 2014 6:51 AM
Points: 2,145, Visits: 2,149
Comments posted to this topic are about the item Creating Tables
Post #1418057
Posted Saturday, February 9, 2013 3:10 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, November 6, 2014 1:00 PM
Points: 5,333, Visits: 25,277
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
Post #1418058
Posted Sunday, February 10, 2013 6:15 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 7:51 PM
Points: 17,948, Visits: 15,947
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
Post #1418160
Posted Sunday, February 10, 2013 10:17 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:43 AM
Points: 1,940, Visits: 2,375
Good basic question to start the week.....


_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1418201
Posted Sunday, February 10, 2013 10:22 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 5:18 AM
Points: 402, Visits: 159
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
Post #1418204
Posted Sunday, February 10, 2013 10:42 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, July 31, 2014 7:15 PM
Points: 1,129, Visits: 1,163
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
Post #1418207
Posted Sunday, February 10, 2013 11:08 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, November 17, 2014 2:13 AM
Points: 276, Visits: 241
nice question... starting with basic morning....

Manik
You cannot get to the top by sitting on your bottom.
Post #1418215
Posted Sunday, February 10, 2013 11:33 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
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?
Post #1418220
Posted Sunday, February 10, 2013 11:43 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:52 AM
Points: 13,528, Visits: 11,323
For me the question was more about the fact you can use Integer instead of int. Didn't know that
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?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1418223
Posted Monday, February 11, 2013 1:02 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, July 31, 2014 7:15 PM
Points: 1,129, Visits: 1,163
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 :D

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


+1
I missed that :D


~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one
Post #1418239
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse