November 22, 2010 at 8:26 pm
Comments posted to this topic are about the item T-SQL GO statement
November 23, 2010 at 12:33 am
Nice command. Thanks
Thanks
November 23, 2010 at 1:14 am
Ha! I never knew one could do that with GO.
Thanks!
November 23, 2010 at 1:20 am
Good point, thanks
Iulian
November 23, 2010 at 2:00 am
I like the point the question tried to make, namely using the GO statement as an instrument to loop, but I do not like the trickery with the # name. At first, I did not even notice the GO 100 statement, as I was focusing on the table name. So I'm confused what this question actually tried to do: teach us about GO n (mission accomplished), or about the various options for table names or was it just to trick people into choosing the wrong answer?
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
November 23, 2010 at 2:12 am
Nice information, thanks..
November 23, 2010 at 2:25 am
Good Question to ask !!!
--------------------------------------------------------------------------------
Mayank Parmar
Software Engineer
Clarion Technologies
SEI CMMI Level 3 Company
8th Floor, 803, GNFC info Tower,
SG Highway, Ahmedabad - 380 054,
Gujarat, India.
www.clariontechnologies.co.in
Email: mayank.parmar@clariontechnologies.co.in
MSN : mayank.parmar@clariontechnologies.co.in
Mobile: +91 9727748789
--------------------------------------------------------------------------------
November 23, 2010 at 3:18 am
da-zero (11/23/2010)
I like the point the question tried to make, namely using the GO statement as an instrument to loop, but I do not like the trickery with the # name. At first, I did not even notice the GO 100 statement, as I was focusing on the table name. So I'm confused what this question actually tried to do: teach us about GO n (mission accomplished), or about the various options for table names or was it just to trick people into choosing the wrong answer?
Yeah, I fell down on this one as well... however, when I did actually try to run the code it didn't seem to like the "100"... I got...
(1 row(s) affected)
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near '100'.
The code is identical... I'm running this on a SQL Server 2000 box, but I don't think that matters...
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
November 23, 2010 at 3:31 am
Try
INSERT INTO #
SELECT 'ASDF'
GO 0
GO <ZERO> --- SQL doesn't throw any complilation error but when you execute the code, status bar should display: "Query completed with errors".
Thanks
November 23, 2010 at 3:50 am
November 23, 2010 at 3:51 am
Hardy21 (11/23/2010)
Try
INSERT INTO #
SELECT 'ASDF'
GO 0
GO <ZERO> --- SQL doesn't throw any complilation error but when you execute the code, status bar should display: "Query completed with errors".
Nope, doesn't like the 0 (zero) either.
I think it is the old version of SQL... further investigation does seem to suggest it.
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
November 23, 2010 at 3:55 am
It's also worth mentioning that GO is not a T-SQL statement. It is a command only recognized by SSMS, sqlcmd and osql, so it can't be used in any T-SQL code that is not executed in any of the three applications mentioned. In other words, SQL Server does not know what GO is.
From BOL:
"SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO."
November 23, 2010 at 4:07 am
DougieCow (11/23/2010)
Hardy21 (11/23/2010)
Try
INSERT INTO #
SELECT 'ASDF'
GO 0
GO <ZERO> --- SQL doesn't throw any complilation error but when you execute the code, status bar should display: "Query completed with errors".
Nope, doesn't like the 0 (zero) either.
I think it is the old version of SQL... further investigation does seem to suggest it.
I have executed the code against SQL Server 2008 R2.
Thanks
November 23, 2010 at 4:17 am
Hardy21 (11/23/2010)
DougieCow (11/23/2010)
Hardy21 (11/23/2010)
Try
INSERT INTO #
SELECT 'ASDF'
GO 0
GO <ZERO> --- SQL doesn't throw any complilation error but when you execute the code, status bar should display: "Query completed with errors".
Nope, doesn't like the 0 (zero) either.
I think it is the old version of SQL... further investigation does seem to suggest it.
I have executed the code against SQL Server 2008 R2.
I have also executed on SQL Server 2008 R2. It gave "Query completed with errors" but no error message.
November 23, 2010 at 4:26 am
Brigadur (11/23/2010)
Hardy21 (11/23/2010)
DougieCow (11/23/2010)
Hardy21 (11/23/2010)
Try
INSERT INTO #
SELECT 'ASDF'
GO 0
GO <ZERO> --- SQL doesn't throw any complilation error but when you execute the code, status bar should display: "Query completed with errors".
Nope, doesn't like the 0 (zero) either.
I think it is the old version of SQL... further investigation does seem to suggest it.
I have executed the code against SQL Server 2008 R2.
I have also executed on SQL Server 2008 R2. It gave "Query completed with errors" but no error message.
Correct.
Also if you execute the: select * from #
GO 0 then also it should display: "Query completed with errors" in status bar, and doesn't display any data in grid due to code is not executed.
Thanks
Viewing 15 posts - 1 through 15 (of 46 total)
You must be logged in to reply to this topic. Login to reply