| Author |
Topic  |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 03:44:13
|
Hi All, I am getting the below error message while executing the below mentioned script as a whole. but when I split the Drop part and GO part and Create Part seperately then its works fine. any Idea why the script is showing error message due to GO keyword.
Error msg :
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'GO'. Msg 111, Level 15, State 1, Line 1 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Proc which I used : IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ES_TestTable]') AND type in (N'P', N'PC')) DROP PROCEDURE [dbo].[ES_TestTable]
GO
CREATE PROC [dbo].[ES_TestTable] ( @ErrorCode varchar(512) = Null OUTPUT ) AS BEGIN SET NOCOUNT ON
BEGIN TRY
SELECT [id], [name] FROM TestTable
END TRY
BEGIN CATCH SET @ErrorCode = CHAR(10) + 'Error while retrieving Testtable.' RETURN END CATCH
SET NOCOUNT OFF
END
Karthik http://karthik4identity.blogspot.com/ |
|
|
Lumbago
Norsk Yak Master
Norway
3241 Posts |
Posted - 03/23/2010 : 04:07:58
|
I just ran this on my system and it works perfectly with no changes whatsoever. Everything ran in one batch. Are you sure this is the exact script that is being executed? How are you executing it?
- Lumbago If the facts don't fit the theory, change the facts. Albert Einstein |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 04:14:20
|
Lumbago, Thanks for the Reply,I executed the same script and get error The code is correct but I guess some settings has been changed so that it is not using the GO statement in my machine. any Idea..?
Karthik http://karthik4identity.blogspot.com/ |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 04:17:09
|
and also when I use GO in other case like.
select 10 GO select 20
then the resut is
GO ----------- 10
(1 row(s) affected)
----------- 20
(1 row(s) affected)
the keyword GO has become the column header.
Karthik http://karthik4identity.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22461 Posts |
Posted - 03/23/2010 : 04:21:06
|
In the menu Goto Query-->Query Options Check what the Batch seperator is under Execution-->General
Madhivanan
Failing to plan is Planning to fail |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 04:23:13
|
quote: Originally posted by madhivanan
In the menu Goto Query-->Query Options Check what the Batch seperator is under Execution-->General
Madhivanan
Failing to plan is Planning to fail
I have cheked that The batch separator is GO
Karthik http://karthik4identity.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22461 Posts |
Posted - 03/23/2010 : 04:26:56
|
It is becuase GO is not in the seperate line Put it in seperate line and see what happens
Madhivanan
Failing to plan is Planning to fail |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 04:29:53
|
quote: Originally posted by madhivanan
It is becuase GO is not in the seperate line Put it in seperate line and see what happens
Madhivanan
Failing to plan is Planning to fail
Thanks for your reply, I have tested it Its in the seperate line only. but still I guess It could be settings Problem.
Karthik http://karthik4identity.blogspot.com/ |
 |
|
|
DBA in the making
Aged Yak Warrior
636 Posts |
Posted - 03/23/2010 : 07:09:00
|
quote: Originally posted by karthik_padbanaban
quote: Originally posted by madhivanan
In the menu Goto Query-->Query Options Check what the Batch seperator is under Execution-->General
I have cheked that The batch separator is GO
Clear the text box and retype "GO" in it, or click the Reset to Default button on the Query Options dialog.
There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 07:18:29
|
quote: Originally posted by DBA in the making
quote: Originally posted by karthik_padbanaban
quote: Originally posted by madhivanan
In the menu Goto Query-->Query Options Check what the Batch seperator is under Execution-->General
I have cheked that The batch separator is GO
Clear the text box and retype "GO" in it, or click the Reset to Default button on the Query Options dialog.
There are 10 types of people in the world, those that understand binary, and those that don't.
No this didnt worked.
Karthik http://karthik4identity.blogspot.com/ |
 |
|
|
DBA in the making
Aged Yak Warrior
636 Posts |
Posted - 03/23/2010 : 08:13:37
|
Buggered if I know. Are you having this problem when logged into the server, or a remote machine?
There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 08:41:16
|
quote: Originally posted by DBA in the making
Buggered if I know. Are you having this problem when logged into the server, or a remote machine?
There are 10 types of people in the world, those that understand binary, and those that don't.
I am logging in my local machine not in Remote
Karthik http://karthik4identity.blogspot.com/ |
 |
|
|
Kristen
Test
United Kingdom
22191 Posts |
Posted - 03/23/2010 : 08:52:39
|
Just to be sure you are using this from SSMS?
From DOCs: "GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor" |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 08:59:24
|
quote: Originally posted by Kristen
Just to be sure you are using this from SSMS?
From DOCs: "GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor"
Ya I am very much sure about using SSMS.
Karthik http://karthik4identity.blogspot.com/ |
 |
|
|
DBA in the making
Aged Yak Warrior
636 Posts |
Posted - 03/23/2010 : 09:05:06
|
If it's happening on a remote machine, that only has SSMS installed (ie, not SQL Server), then I'd try logging into the server, or another client machine with SSMS, and see if the problem exists there as well (I can't see why it would, as the GO statement is handled locally by the SSMS, not by the server, by try it anyway). If it doesn't, then uninstall and re-install SSMS.
There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
India
263 Posts |
Posted - 03/23/2010 : 09:27:50
|
quote: Originally posted by DBA in the making
If it's happening on a remote machine, that only has SSMS installed (ie, not SQL Server), then I'd try logging into the server, or another client machine with SSMS, and see if the problem exists there as well (I can't see why it would, as the GO statement is handled locally by the SSMS, not by the server, by try it anyway). If it doesn't, then uninstall and re-install SSMS.
There are 10 types of people in the world, those that understand binary, and those that don't.
I think It would be a settings problem.
Karthik http://karthik4identity.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22461 Posts |
Posted - 03/23/2010 : 09:59:05
|
Are you sure you are connected to correct server? Try closing SSMS and see if you get error again
Madhivanan
Failing to plan is Planning to fail |
Edited by - madhivanan on 03/23/2010 10:00:27 |
 |
|
|
Lijo Cheeran Joseph
Posting Yak Master
123 Posts |
Posted - 06/19/2011 : 04:34:51
|
I too have similar problem.. The batch separator is "GO". I opened the query in Management Studio after going into the server.
There is a DROP temp table statement just before the END of an SP. I pressed enter after the DROP statement and wrote GO. It says "Incorrect syntax near '#tempZipCodeUpload'."
Note: When I type the following in a separate window; it works fine; the column headers are 'No Column Name' select 10 GO select 20
Any editor available to create the correct new line?
Any thoughts? |
Edited by - Lijo Cheeran Joseph on 06/19/2011 04:39:13 |
 |
|
|
webfred
Flowing Fount of Yak Knowledge
Germany
8515 Posts |
Posted - 06/19/2011 : 08:09:39
|
quote: Originally posted by Lijo Cheeran Joseph
I too have similar problem.. The batch separator is "GO". I opened the query in Management Studio after going into the server.
There is a DROP temp table statement just before the END of an SP. I pressed enter after the DROP statement and wrote GO. It says "Incorrect syntax near '#tempZipCodeUpload'."
Note: When I type the following in a separate window; it works fine; the column headers are 'No Column Name' select 10 GO select 20
Any editor available to create the correct new line?
Any thoughts?
You should open a new thread AND show your code AND show the complete error message.
No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
mkkwan00
Starting Member
Singapore
1 Posts |
Posted - 12/04/2012 : 22:28:37
|
u copy and paste ur string to notepad.. if u see the go is within a same line or not ?
E.g use testgo etc..
if yes, then manually edit on the notepad and copy back to SSMS |
 |
|
|
Law2rence
Starting Member
USA
6 Posts |
Posted - 12/11/2012 : 08:45:57
|
Thanks for the Reply,I executed the same script and get error



 |
Edited by - Law2rence on 12/11/2012 08:53:54 |
 |
|
| |
Topic  |
|