Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 What's the problem for db creation script

Author  Topic 

kamii47
Constraint Violating Yak Guru

353 Posts

Posted - 2012-05-17 : 02:09:58
I have following script for database creation.
(which is working fine a month back.Certainly i am getting difference in script (I use adeptsqldiff for comparison))

use master
/* SEQ01_CREATE_DATABASE */
DECLARE @SQL VARCHAR(MAX)
DECLARE @DBName VARCHAR(50)
DECLARE @DBPath VARCHAR(255)

SET @DBName = 'CustomerDBName'

SELECT @DBPath = SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1)
FROM master.sys.master_files
WHERE database_id = 1 AND file_id = 1

IF EXISTS(SELECT name FROM sys.databases
WHERE name = @DBName)
exec('DROP DATABASE ['+ @DBName+']')

SET @SQL = '

CREATE DATABASE [' + @DBName + ']
ON
PRIMARY
(NAME = [' + @DBName + '],
FILENAME = '''+ @DBPath + @DBName + '.mdf'',
SIZE = 200MB,
FILEGROWTH = 100MB);
ALTER DATABASE [' + @DBName + ']
MODIFY FILE ( NAME = ''' + @DBName + '_log'', MAXSIZE = 2048GB , FILEGROWTH = 100MB);
Alter DATABASE [' + @DBName + ']
Set ALLOW_SNAPSHOT_ISOLATION ON;'
EXEC (@SQL)
GO

USE [CustomerDBName]

Go



Kamran Shahid
Principle Engineer Development
(MCSD.Net,MCPD.net)

Sachin.Nand

2937 Posts

Posted - 2012-05-17 : 02:20:19
So whats the question ?

After Monday and Tuesday even the calendar says W T F ....
Go to Top of Page

kamii47
Constraint Violating Yak Guru

353 Posts

Posted - 2012-05-17 : 02:23:08
Is there any problem appearing in this script?


Kamran Shahid
Principle Engineer Development
(MCSD.Net,MCPD.net)

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2012-05-17 : 03:33:36
I tried it and its working fine for me.

After Monday and Tuesday even the calendar says W T F ....
Go to Top of Page

ivycool
Starting Member

3 Posts

Posted - 2012-05-25 : 00:06:42
Is there any problem appearing in this script?
unspammed

Bree Vandicamp
Go to Top of Page
   

- Advertisement -