Add-SqlDataFile

Adds a new dataFile to a filegroup.

Syntax

Add-SqlDataFile [-filegroup] <FileGroup> [-name] <String> [-filepath] <String> [[-size] <Double>] [[-growthType] {KB | Percent | None}] [[-growth] <Double>] [[-maxSize] <Double>] [<CommonParameters>]

Detailed Description

The Add-SqlDataFile function adds a new DataFile to the specified filegroup.

Related Commands

* Add-SqlDataFile
* Add-SqlFileGroup
* Add-SqlDatabase
* Get-SqlDatabase

Parameters

Name Description Required? Pipeline Input Default Value
filegroup    true  false   
name    true  false   
filepath    true  false   
size    false  false   
growthType    false  false   
growth    false  false   
maxSize    false  false   

Input Type

None You cannot pipe objects to Add-SqlDataFile

Return Values

Microsoft.SqlServer.Management.Smo.DataFile Add-SqlDataFile returns an Microsoft.SqlServer.Management.Smo.DataFile object.

Notes

Add-SqlDataFile is used by Add-SqlDatabase.

Examples

EXAMPLE 1

$database = Get-SqlDatabase "Z002\sql2k8" "pubs"
$fileGroup = Add-SqlFileGroup $database 'FileGroup2'
Add-SqlDataFile -filegroup $fileGroup -name 'pubs_DataFile1'  -filepath 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2K8\MSSQL\DATA\pubs_DataFile1.ndf'
$database.Alter()
This command adds the DataFile DataFile2 to the pubs database.