Programitically is there a way to test for the existance of a MS Sql database in this case called 'Vehicle' then run a setup script :
- Code: Select all Expand view
USE [master]
GO
/****** Object: Database [Vehicle] Script Date: 09/01/2010 13:39:03 ******/
CREATE DATABASE [Vehicle] ON PRIMARY
( NAME = N'Vehicle', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Vehicle.mdf' , SIZE = 97280KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Vehicle_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Vehicle_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [Vehicle] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Vehicle].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [Vehicle] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [Vehicle] SET ANSI_NULLS OFF
GO
ALTER DATABASE [Vehicle] SET ANSI_PADDING OFF
GO
ALTER DATABASE [Vehicle] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [Vehicle] SET ARITHABORT OFF
GO
ALTER DATABASE [Vehicle] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [Vehicle] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [Vehicle] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [Vehicle] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [Vehicle] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [Vehicle] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [Vehicle] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [Vehicle] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [Vehicle] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [Vehicle] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Vehicle] SET DISABLE_BROKER
GO
ALTER DATABASE [Vehicle] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [Vehicle] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [Vehicle] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [Vehicle] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [Vehicle] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [Vehicle] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [Vehicle] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [Vehicle] SET READ_WRITE
GO
ALTER DATABASE [Vehicle] SET RECOVERY FULL
GO
ALTER DATABASE [Vehicle] SET MULTI_USER
GO
ALTER DATABASE [Vehicle] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [Vehicle] SET DB_CHAINING OFF
GO
Then once the database is created .. be able to create the tables like :
- Code: Select all Expand view
USE [VEHICLE]
GO
/****** Object: Table [dbo].[USERINFO] Script Date: 05/28/2008 15:49:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[USERINFO](
[USEREID] [char](18) NOT NULL,
[AGENEID] [char](18) NULL,
[AGENCY] [char](10) NULL,
[USERID] [char](8) NULL,
[READ] [char](1) NULL,
[WRITE] [char](1) NULL,
[SUPER] [char](1) NULL,
[TECH] [char](1) NULL,
[MGR] [char](1) NULL,
[ADMIN] [char](1) NULL,
[PASSWORD] [char](10) NULL,
[LASTLOG] [datetime] NULL,
CONSTRAINT [PK_USERINFO] PRIMARY KEY CLUSTERED
(
[USEREID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
I would then have to create the database user and password and grant them security to the SQL box and add them to the security of the database with datareader and datawriter ??
I am trying to create an application setup disk to automatically create a SQL database, tables and permissions for the application connection string ..
Don't know if the above is actually possible under FWH control or maybe a batch file called by my application ??
Thanks
Rick Lipkin