Execute Sql query in umbraco during package installation

Scenario:
  How to create table in Sql by action script during package installation in umbraco.
  How to create stored procedure by action script during package installation in umbraco.

Well this is common scenario where you want to create some table and stored procedure
and many more related to your package and application.So how we will accomplish
this task.
For accomplish this task use

<Action runat="install" undo="true" alias="ExecuteSql">
<![CDATA[----Enter Your Sql Statement here--- ]]>
</Action>

Here is Example for table creation in sql server 2008:

Note1: Alias name can be any thing you want.
Note2: Make sure that your action script doesn’t contains any blank space
other wise it will not going to execute.

<Action runat="install" undo="true" alias="ExecuteSql"><
![CDATA[
CREATE TABLE [uTasklist_Task](
[task_id] [int] IDENTITY(1,1) NOT NULL,
[task_details] [ntext] NOT NULL,
[create_date] [datetime] NOT NULL,
CONSTRAINT [PK_uTasklist_Task] PRIMARY KEY CLUSTERED
(
[task_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]]]>
</Action>

Here is example for stored procedure creation in sql server 2008 during package installation.

<Action runat="install" undo="true" alias="ExecuteSql">
<![CDATA[
CREATE PROC [uTasklist_SetTasklist]
@task_details [NTEXT], @create_date [DATETIME]
AS
SET NOCOUNT ON
INSERT INTO [uTasklist_Task] VALUES(@task_details, @create_date)]]>
</Action>

Here is Another good link for: Package installation tools for Umbraco @ codePlax

Advertisements

4 thoughts on “Execute Sql query in umbraco during package installation

  1. Pingback: Execute Sql query in umbraco during package installation « Nishant works @ Umbraco

  2. Pingback: Umbraco: How to Create Custom data type in umbraco using c#. | [Code Destination]

  3. Pingback: Create your first Rss Feed Burner in umbraco | [Code Destination]

  4. Pingback: Install umbraco manually. | [Code Destination]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s