'CREATE/ALTER PROCEDURE' must be the first statement in a query batch


#1

Guys @aksh1yadav @vvaidya @beesheep @Vikas.Jain @andrzej.kniola,

I have a stored procedure starting as below in a .sql file,

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

GO
IF OBJECT_ID(‘SP_ABCDEF’) IS NULL
EXEC(‘CREATE PROCEDURE DBO.SP_ABCDEF’)
GO
ALTER PROCEDURE DBO.SP_ABCDEF

AS

BEGIN

blah blah blah

GO

when I read this file and pass the content as query string to execute query activity, I see the below
error,

.Net SqlClient Data Provider : Incorrect syntax near 'GO’
Incorrect syntax near the keyword ‘ALTER’.
’CREATE/ALTER PROCEDURE’ must be the first statement in a query batch.

I don’t want to change anything and just run it as it is in the SQL file… Please see if you guys can share your thoughts around this,

Thanks!


#2

Hi Dilli,

Did you find solution for this problem?

Thanks,
Ashok


#3

Unfortunately, no.

Appreciate if you can share any ideas to run stored procedures.

Thanks-Dilli.!


#4

Hi Dilli,

I removed Go in the query and it worked.

Thanks,
Ashok