Please Help with Transaction + Alter Procedure statement

From: Roger James Jr (robin.marshall_at_gmail.com)
Date: 10/01/04


Date: 30 Sep 2004 18:17:48 -0700

Hi,

I am struggling with the following SQL. Can anyone help me please.
What is the problem?

Errors:
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'PROCEDURE'.
Server: Msg 137, Level 15, State 1, Line 14
Must declare the variable '@mySomething'.

BEGIN TRANSACTION myTransaction

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id =
object_id(N'[mytable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN

ALTER PROCEDURE myProcedure
(
   @myID INT,
   @mySomething VARCHAR(255)
)
AS

SELECT
   @mySomething + myFieldValue AS myDesiredResult
FROM
   myTable

END

COMMIT TRANSACTION myTransaction



Relevant Pages

  • Re: Random Number Function
    ... > doing a batch update to the table from MS Access, ... > DECLARE @RandomNumber DOUBLE ... > Incorrect syntax near the keyword 'SET'. ...
    (microsoft.public.sqlserver.programming)
  • Re: Incorrect syntax near the keyword Close
    ... Wayne Snyder, MCDBA, SQL Server MVP ... I support the Professional Association of SQL Server and it's community of SQL Server professionals. ... > Incorrect syntax near the keyword 'Close'. ...
    (microsoft.public.sqlserver.server)
  • Problem SQL ADO
    ... Using Python on WinXP going against MS SQL 2000 server. ... Provider for SQL Server', "Incorrect syntax near the keyword 'INNER'.", ...
    (comp.lang.python)
  • Re: Testing Table Existence - DB name as variable ?
    ... Your Else condition doesnt have a ... SQL Server Programmer ... > As is, Error is Incorrect syntax near keyword 'ELSE'> If I comment out from BEGIN to the END, Error is Incorrect syntax near ')'> ... > DECLARE @SalespersonDB as varchar> ...
    (microsoft.public.sqlserver.programming)
  • Re: Help I am getting an error when I run my insert statement
    ... Microsoft OLE DB Provider for SQL Server error '80040e14' ... Incorrect syntax near the keyword 'Plan'. ... startdate, finshdate,revfinish are all smalldatetime ...
    (microsoft.public.sqlserver.odbc)