Amit D.Shinde (amit_sd01@yahoo.com) writes:
[quoted text, click to view] > 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?
[quoted text, click to view] > 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.)
[quoted text, click to view] > 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, esquel@sommarskog.se
Books Online for SQL Server SP3 at