• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1492
  • Last Modified:

ALTER FUNCTION' must be the first statement in a query batch.

I've got a huge SQL script (184,000 lines) updating various functions, sps, inserts data, updates data etc that was given to me and I want to put it inside a transaction for obvious reasons.

Here's the start to it:

SET XACT_ABORT ON  

      SET NOCOUNT ON;

      SET QUOTED_IDENTIFIER OFF      

      SET ANSI_NULLS ON


begin transaction

alter FUNCTION dbo.FunctionNamedRemoved
(@uid uniqueidentifier,
@AccessDate datetime
)

etc, etc

but I get:

Msg 111, Level 15, State 1, Line 21
'ALTER FUNCTION' must be the first statement in a query batch.
Msg 137, Level 15, State 2, Line 46
Must declare the variable '@uid'.

Why could I be getting this?
0
PeterErhard
Asked:
PeterErhard
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
SET XACT_ABORT ON  

      SET NOCOUNT ON;

      SET QUOTED_IDENTIFIER OFF      

      SET ANSI_NULLS ON


begin transaction
GO
alter FUNCTION dbo.FunctionNamedRemoved
(@uid uniqueidentifier,
@AccessDate datetime
)

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now