Click here to Skip to main content
15,896,726 members
Home / Discussions / Database
   

Database

 
QuestionDatabase column Pin
Verghese25-Jul-08 9:10
Verghese25-Jul-08 9:10 
AnswerRe: Database column Pin
Blue_Boy25-Jul-08 11:59
Blue_Boy25-Jul-08 11:59 
QuestionCrystal Report Title @ Run Time Pin
Verghese25-Jul-08 5:33
Verghese25-Jul-08 5:33 
AnswerRe: Crystal Report Title @ Run Time Pin
SomeGuyThatIsMe25-Jul-08 5:52
SomeGuyThatIsMe25-Jul-08 5:52 
AnswerRe: Crystal Report Title Pin
David Mujica25-Jul-08 6:32
David Mujica25-Jul-08 6:32 
GeneralRe: Crystal Report Title Pin
Verghese25-Jul-08 9:17
Verghese25-Jul-08 9:17 
AnswerRe: Crystal Report Title @ Run Time Pin
Wendelius25-Jul-08 10:17
mentorWendelius25-Jul-08 10:17 
QuestionDynamic Database Creation ?? Pin
C. L. Phillip25-Jul-08 4:13
C. L. Phillip25-Jul-08 4:13 
I’m creating a SQL script for an installation package that I’m working on. I want to parameterize the database creation process. Wants to be able to set the database name in a variable, and have the SQL script use that variable to create the database and the necessary tables.
So far … this part works to create the database

USE [master]

/****** Object:  Database [FCDB]    Script Date: 07/24/2008 23:21:04 ******/
DECLARE @DBName varchar(60)
DECLARE @DBDir  varchar(100)
DECLARE @SQL    varchar(MAX)

SET @DBName = N'Test'
SET @DBDir = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\'

SET @SQL = N'CREATE DATABASE ' + @DBName + ' ON  PRIMARY 
      ( NAME = "' + @DBName + '", 
      FILENAME = "'+@DBDir + @DBName + '.mdf" , 
      SIZE = 4048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
      LOG ON 
      ( NAME = "' + @DBName + '-01_log", 
      FILENAME = "'+@DBDir + @DBName + '_log.ldf" , 
      SIZE = 4096KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)'
EXEC (@SQL)

EXEC dbo.sp_dbcmptlevel @dbname=@DBName, @new_cmptlevel=90

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC (@DBName + '.[dbo].[sp_fulltext_database] @action = "enable"')
End


However, I can’t seem to switch to the database in script, and create the tables in it
I’ve tried -> EXEC ('USE ' + @DBName)
And also -> USE @DBName

Could you help me please ? Thank you for your time


Cecil L. Phillip
AnswerRe: Dynamic Database Creation ?? Pin
TheFM23425-Jul-08 4:42
TheFM23425-Jul-08 4:42 
GeneralRe: Dynamic Database Creation ?? Pin
C. L. Phillip25-Jul-08 4:49
C. L. Phillip25-Jul-08 4:49 
AnswerRe: Dynamic Database Creation ?? Pin
TheFM23425-Jul-08 5:14
TheFM23425-Jul-08 5:14 
GeneralRe: Dynamic Database Creation ?? Pin
C. L. Phillip25-Jul-08 5:23
C. L. Phillip25-Jul-08 5:23 
GeneralRe: Dynamic Database Creation ?? Pin
BhadeliaImran26-Jul-08 1:53
BhadeliaImran26-Jul-08 1:53 
AnswerRe: Dynamic Database Creation ?? Pin
Wendelius25-Jul-08 9:53
mentorWendelius25-Jul-08 9:53 
AnswerRe: Dynamic Database Creation ?? Pin
Mycroft Holmes25-Jul-08 22:39
professionalMycroft Holmes25-Jul-08 22:39 
GeneralRe: Dynamic Database Creation ?? Pin
C. L. Phillip27-Jul-08 5:41
C. L. Phillip27-Jul-08 5:41 
QuestionSqlserver datatabase deployment along with setup file Pin
vishnukamath25-Jul-08 1:45
vishnukamath25-Jul-08 1:45 
AnswerRe: Sqlserver datatabase deployment along with setup file Pin
C. L. Phillip25-Jul-08 4:09
C. L. Phillip25-Jul-08 4:09 
QuestionCreating SQL view Pin
Ranojay25-Jul-08 1:02
Ranojay25-Jul-08 1:02 
AnswerRe: Creating SQL view Pin
ChandraRam25-Jul-08 2:08
ChandraRam25-Jul-08 2:08 
AnswerRe: Creating SQL view Pin
samrat.net25-Jul-08 3:15
samrat.net25-Jul-08 3:15 
GeneralMSSQL stopped mysteriously Pin
Brady Kelly24-Jul-08 23:40
Brady Kelly24-Jul-08 23:40 
GeneralRe: MSSQL stopped mysteriously Pin
DerekFL25-Jul-08 8:22
DerekFL25-Jul-08 8:22 
GeneralRe: MSSQL stopped mysteriously Pin
Brady Kelly25-Jul-08 23:00
Brady Kelly25-Jul-08 23:00 
JokeRe: MSSQL stopped mysteriously Pin
Mycroft Holmes25-Jul-08 23:10
professionalMycroft Holmes25-Jul-08 23:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.