Groups | Blog | Home
all groups > sql server programming > april 2004 >

sql server programming : Query about a Stored proc..


Vamsi
4/11/2004 11:06:16 PM
hi,
i have a stored proc which is like this..


if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[Code_Testing1]') and OBJECTPROPERTY
(id, N'IsProcedure') = 1)
drop procedure [dbo].[Code_Testing1]
GO
Print 'Creating procedure Code_Testing ....'


CREATE PROCEDURE dbo.Code_Testing1
@inCountry varchar(255) = '' -- Country
for the Pricelist
, @inDebug int = 0 -- Debug
parameter
AS

........so on the code continues.

Why does this give me errors??
when i remove the Print stmt above it works just fine.
The problem has something to go with the Print stmt
before Create Procedure stmt.
I get the erros @inCountry ,@inDebug not declared and
soon..

My question is why cant i use the Print stmt here??
Vamsi
4/11/2004 11:33:57 PM
Thanks a lot guys.

[quoted text, click to view]
Aaron Bertrand [MVP]
4/12/2004 2:16:11 AM
[quoted text, click to view]

Usually, it's helpful if you describe that a little bit better, e.g. WHAT
error message, on WHAT line?

However, it's relatively clear from your code, and should be clear from the
error message. The parser is a complicated but largely unintelligent beast.
You must put CREATE PROCEDURE at the beginning of a batch. So, instead of:

stuff
GO
PRINT
CREATE PROCEDURE

Simply change it to:

stuff
GO
PRINT
GO
CREATE PROCEDURE

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/

SriSamp
4/12/2004 11:51:10 AM
You just need to put a GO after the PRINT, since CREATE PROCEDURE must be
the first statement in a batch.
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp

[quoted text, click to view]

AddThis Social Bookmark Button