473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Urgent; Incorrect Syntax Near Go Help

Hi Experts,
i am writting a stored procedure in sql server 7. Its a simple stored
procedure
It is my first stored procedure.
I want insert a record in table if the primary key field user id
already does not exists. if it exists SP should pass 0 as output else
if insert is successfull it should pass 1 to calling sp.
But following SP raising an ERRor" Incorrect Syntax near 'GO'
help
It is as follows

Create Procedure Sp_FillUserDetails
@UserId varchar(50),
@Password varchar(50),
@DOB DateTime,
@Gender varchar(6),
@Address varchar(250),
@City varchar(50),
@State varchar(20),
@Country varchar(20),
@ZIp varchar(15),
@Phone1 varchar(15),
@Mobile varchar(15),
@Email varchar(100),
@CCName varchar(25),
@CCno varchar(25),
@ExipiryDate DateTime,
@Question varchar(60),
@Answer varchar(50),
@Result int output

AS

If exists(Select * from Users where userid=@UserID)
set @Result=0
Else
Insert into Users (Userid, Password, dob, Gender, Address, City,
State, Country, Zipcode,Phone1, Mobile, EmailID, CCname, CCno,
expirydate, Question, Answer) values
(@UserId, @Password ,@DOB ,@Gender ,@Address ,@City ,@State ,@Country
,@ZIp ,@Phone1 ,@Mobile,@Email ,@CCName ,@CCno ,@ExipiryDate
,@Question ,@Answer)

set @result=0

GO
Jul 20 '05 #1
1 9882
Amit D.Shinde (am*******@yahoo.com) writes:
i am writting a stored procedure in sql server 7. Its a simple stored
procedure
It is my first stored procedure.
So that's why it's urgent?
I want insert a record in table if the primary key field user id
already does not exists. if it exists SP should pass 0 as output else
if insert is successfull it should pass 1 to calling sp.
But following SP raising an ERRor" Incorrect Syntax near 'GO'
help
It seems that somehow you are using a tool where GO is not a batch
terminator. GO is as far as SQL Server is concerned just another two-
letter identifier. Tools usually uses GO as a batch separator, which
means that if you have:

SELECT this FROM tbl
go
SELECT that FROM tbl
go
SELECT thisandthat FROM tbl

the tool will pass the three SELECT statements one at a time to SQL Server,
whereas if you remove the "go"s, SQL Server get all three statements at
once. In neither case, SQL Server will not see "go" itself.

Tip: if you are using Enterprise Manager to write your stored procedures,
stop doing that. Use Query Analyzer instead, since this is a far better
editor. (Although QA in SQL7 is a bit bleak compared to QA in SQL2000, as
I recall.)
Create Procedure Sp_FillUserDetails


Don't use sp_ in the name of your stored procedures. This prefix is
reserved for system procedures, and SQL Server first looks for such
procedure in the master database.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dharmesh Gandhi | last post by:
DB-Library Error 10007: General SQL Server error: Check messages from the SQL Server. CREATE PROCEDURE . ( @srvr varchar(50),
1
by: Jeff Magouirk | last post by:
Dear Group, I am trying to create a view and keep getting the Incorrect syntax near the keyword 'Declare'" error. Here is the code I am writing. Create view fixed_airs (sid, fad_a2, fad_a3)...
2
by: JMUApache | last post by:
Hi, I have got a error message while I run a sample OLEDB program. It says "Incorrect Syntax Near The Keyword Default Information". platform: Windows XP + Visual Studio 2005 Beta 2 + SQL...
1
by: Sandesh | last post by:
Hello All, Me saying " has any body come across such error would be underestimating". Well I am getting a very peculiar and unique error "Line 1: Incorrect syntax near 'Actions'." ...
1
by: iporter | last post by:
In the following code, the two Response.Write statements output exactly the same - I can copy and paste both into Query Analyzer, and run them fine. However, if I comment out line 3, the...
1
by: Dax | last post by:
When i insert some values float in a form made with ASP appear an error message like this: Microsoft OLE DB Provider for SQL Server (0x80040E14) Line 1: Incorrect syntax near ','. sql="select...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
10
by: arial | last post by:
Hi, I am getting this error message: Incorrect syntax near the keyword 'where'. Description: An unhandled exception occurred during the execution of the current web request. Please review...
1
by: karenkksh | last post by:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.