Hi
I am trying to run a liquibase deploy and am getting and error if I place a GO in my SQL file. If I use a ; it seems to be happier however I then get an error stating that ALTER must be the first statement in the batch. If I tell it to split the statements then my initial check to create the function before running the ALTER, fails due to the (I guess) the create being outside of the scope of the ALTER transaction.
I call the SQL file using the following command:
My SQL file looks like this:
IF OBJECT_ID(N’fn_getFinalisedDate’) is null
EXEC sp_ExecuteSQL N’CREATE FUNCTION fn_getFinalisedDate() returns char(35) as begin RETURN ‘‘Function fn_getFinalisedDate() is incomplete’’ end’
GO
ALTER FUNCTION [dbo].[fn_getFinalisedDate] (@transactionref int)
RETURNS datetime
If I generate a full SQL Script and copy paste it into my Query tool, the script runs 100%.
Thanks
Jonathan Russell
Senior SQL DBA