We recommend using Visual Studio 2017

Restore.Script Method

Generates a Transact-SQL script that can be used to re-create the restore operation. 

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.SmoExtended (in Microsoft.SqlServer.SmoExtended.dll)

public StringCollection Script(
	Server server
)

Parameters

server
Type: Microsoft.SqlServer.Management.Smo.Server
A Server object that represents the instance of SQL Server that is targeted by the restore operation.

Return Value

Type: System.Collections.Specialized.StringCollection
A StringCollection system object value that contains a list of Transact-SQL statements in the script.

The generated script might contain undocumented, internal procedures, which are required for the complete script output.

Community Additions

ADD
Show: