SQL Script Drop Procedure - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

Borgas
Posts: 60
Joined: Tue Jan 22, 2008 10:49 pm

SQL Script Drop Procedure

I have 2 Sql sripts running efter each other.
The first Script is deleting all procedures, Functions and assembles
The second is createing Procedures, Functions and assembles

The problem is that the second sql script is executing before the first sql script is finished. Can this be managed by settings or what is wrong?





First SQL Script ************* ${TsPro} is changed to TsPro

SET NOCOUNT ON;

USE [${TsPro}];

DECLARE @Name sysname;
DECLARE @cmd sysname;

/** Delete stored procedures **/
DECLARE PROC_CURSOR CURSOR LOCAL FOR
SELECT name FROM sys.objects WHERE type in (N'P', N'PC');

OPEN PROC_CURSOR;

FETCH NEXT FROM PROC_CURSOR INTO @Name;
WHILE @@FETCH_STATUS = 0 BEGIN
SET @cmd = 'DROP PROCEDURE [' + @Name + ']';
EXEC (@cmd);

FETCH NEXT FROM PROC_CURSOR INTO @Name;
END

CLOSE PROC_CURSOR;
DEALLOCATE PROC_CURSOR;


/** Delete functions **/
DECLARE FUNC_CURSOR CURSOR LOCAL FOR
SELECT name FROM sys.objects WHERE type in (N'FN', N'IF', N'TF', N'FS', N'FT');

OPEN FUNC_CURSOR;

FETCH NEXT FROM FUNC_CURSOR INTO @Name;
WHILE @@FETCH_STATUS = 0 BEGIN
SET @cmd = 'DROP FUNCTION [' + @Name + ']';
EXEC (@cmd);

FETCH NEXT FROM FUNC_CURSOR INTO @Name;
END

CLOSE FUNC_CURSOR;
DEALLOCATE FUNC_CURSOR;


/** Assemblies **/
IF EXISTS (SELECT * FROM sys.assemblies asms WHERE asms.name = N'TsPro Washer')
DROP ASSEMBLY [TsPro Washer];

/** Service broker **/
IF EXISTS (SELECT * FROM sys.services WHERE name = N'WashingService')
DROP SERVICE [WashingService];

IF EXISTS (SELECT * FROM sys.services WHERE name = N'WasherStarterService')
DROP SERVICE [WasherStarterService];

IF EXISTS (SELECT * FROM sys.service_contracts WHERE name = N'WashingContract')
DROP CONTRACT [WashingContract];

IF EXISTS (SELECT * FROM sys.service_message_types WHERE name = N'StartWashing')
DROP MESSAGE TYPE [StartWashing];

IF EXISTS (SELECT * FROM sys.service_queues WHERE name = N'WashingQueue')
DROP QUEUE [dbo].[WashingQueue];

IF EXISTS (SELECT * FROM sys.service_queues WHERE name = N'WasherStarterServiceQueue')
DROP QUEUE [dbo].[WasherStarterServiceQueue];



The Second Procedure is Adding Procedure, Functions, Assembles
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

Please note that by default Advanced Installer will wait until the first script is finished before executing the second script.

However, in order to obtain the desired behavior you need to make sure that in the "SQL Scripts" page the script which deletes the procedures is above the script which creates them.

If the problem persists please send us the AIP to support at advancedinstaller dot com so we can investigate it. Also, can you please specify how do you know that second SQL script is executed before the first SQL script is finished?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Borgas
Posts: 60
Joined: Tue Jan 22, 2008 10:49 pm

Sorry if i dident explaine correctly

Script1 is ececuting before Script2
Script2 is however runing before script1 is finished.


How do i how that this is the case?
because i recive difrent error when script 2 is runing.
Som times is StoreProcedure1 that is failing
Som times is StoreProcedure2 that is failing

I have tryed to use InstallSheld there it is running Correct every time and it's the same settings

So there for i know that the SQL script is OK
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
Script1 is ececuting before Script2
Script2 is however runing before script1 is finished.
Please note that this is not possible because Advanced Installer doesn't allow it. Have you followed our SQL Scripts tutorial?
http://www.advancedinstaller.com/user-g ... l-sql.html

If the problem persists please send us the AIP to support at advancedinstaller dot com so we can investigate it.
How do i how that this is the case?
because i recive difrent error when script 2 is runing.
Som times is StoreProcedure1 that is failing
Som times is StoreProcedure2 that is failing
What exactly are the errors you are receiving, can you please give me more details about this?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Borgas
Posts: 60
Joined: Tue Jan 22, 2008 10:49 pm

Can we use them Email insted then i can send you picturs how i configured my ODBC[/img]

Return to “Common Problems”