SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 What's the problem for db creation script
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kamii47
Constraint Violating Yak Guru

337 Posts

Posted - 05/17/2012 :  02:09:58  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2937 Posts

Posted - 05/17/2012 :  02:20:19  Show Profile  Reply with Quote
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

337 Posts

Posted - 05/17/2012 :  02:23:08  Show Profile  Reply with Quote
Is there any problem appearing in this script?


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

Go to Top of Page

Sachin.Nand
Flowing Fount of Yak Knowledge

2937 Posts

Posted - 05/17/2012 :  03:33:36  Show Profile  Reply with Quote
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

USA
3 Posts

Posted - 05/25/2012 :  00:06:42  Show Profile  Reply with Quote
Is there any problem appearing in this script?
unspammed

Bree Vandicamp
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000