We have a script to generate create db but for one of the databases , It seems to add ALTER
DATABASE ADD FILEGROUP for one db but not other..
Final text looks like this.. Could it be a option ? If it is which one is it?
/****** Object: Database [APIDW] Script Date: 06/30/2015 10:34:05 ******/
CREATE DATABASE [xx] ON PRIMARY
( NAME = xxx', FILENAME = N'Mxx.mdf' , SIZE = 17117184KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1048576KB ),
( NAME = N'xxx'...
ALTER DATABASE xx ADD FILEGROUOP A; ---DON'T NEED THISALTER DATABASE xx ADD FILEGROUOP B; ---DON'T NEED THIS
;CREATE DATABASE [YY] ON PRIMARY
( NAME = xxx', FILENAME = N'Mxx.mdf' , SIZE = 17117184KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1048576KB ),
( NAME = N'xxx'...
..
CREATE DATABASE [ZZ]This script generates create db statements for all online user db
try { ... #Get a server object which corresponds to the default instance $srv = New-Object -TypeName Microsoft.SqlServer.Management.SMO.Server $Inst foreach($db in $srv.databases) { If($db.IsAccessible -and !$db.IsSystemObject -and !$db.IsDatabaseSnapshot) { If($db.name -ne "DBADB") { $db.name $db.script() | out-file $OutFile -append } } } $file = New-Object System.IO.StreamReader -Arg $OutFile $file.Close(); } catch { ExitProg $false $error[0] }
- Edited by SQL_Jay 15 hours 52 minutes ago