How to add a stored procedure in Windows Installer

I have a simple stored procedure as shown below

Create PROCEDURE [dbo].[insertMessage] --@msgTypeName NVARCHAR(50), --@msgTypeDescription NVARCHAR AS BEGIN SET NOCOUNT ON; -- Insert statements for procedure here INSERT INTO [dbo].[tblMessageLookup] (strMessageType, strMessageDescription,DateCreated,DateModified) VALUES ('TrainList', 'TrainList',GETDATE(),GETDATE()); INSERT INTO [dbo].[tblMessageLookup] (strMessageType, strMessageDescription,DateCreated,DateModified) VALUES ('Schedule', 'Schedule',GETDATE(),GETDATE()); INSERT INTO [dbo].[tblMessageLookup] (strMessageType, strMessageDescription,DateCreated,DateModified) VALUES ('Stockpile', 'Stockpile',GETDATE(),GETDATE()); INSERT INTO [dbo].[tblMessageLookup] (strMessageType, strMessageDescription,DateCreated,DateModified) VALUES ('Forecast', 'Forecast',GETDATE(),GETDATE()); END 

If I followed the repository procedure, it will create three rows in my table, but I'm trying to do this process automatically. Therefore, I decided to create a Windows installer for this, because in the rest of the project (Windows application), a Windows Installer is installed to install the project.

Is there a way to create an installer for a stored procedure or add it to an existing Windows installer?

+4
source share
1 answer

MSDN has an article on how to use custom actions in installation projects to create databases during installation.

Walkthrough Using a custom action to create a database during installation

You can change the SQL that they use to create a database with their own code - either to create a procedure, or to execute it, or both (this is not clear from your question that you want to do).

+1
source

All Articles