New-QLRSqlReader

From PowerGUI Wiki

Jump to: navigation, search

Creates a new LogReader object.

Contents

Syntax

New-QLRSqlReader [-Online] [-ServerName] <String> [-DatabaseName] <String> [[-LoginMode] [<AuthMode>]] [[-Login] [<String>]] [[-Password] [<String>]] [-ConfigFile [<String>]] [-LogBackup [<String[]>]] [<CommonParameters>] New-QLRSqlReader [-Offline] [-PrimaryDataFile] <String> [-SecondaryFile] <String[]> [-LogBackup [<String[]>]] [<CommonParameters>] New-QLRSqlReader [-Backup] [-FullBackup] <String> [-LogBackup [<String[]>]] [<CommonParameters>]

Detailed Description

The New-QLRSqlReader cmdlet creates a new LogReader object and loads the transaction log into it.



Related Commands

Parameters

Name Description Required? Pipeline Input Default Value
Online Set this parameter to read an online transaction log. true false
ServerName The SQL Server instance name. This parameter is used only if the Online parameter it set. true false
DatabaseName The database name. This parameter is used only if the Online parameter it set. true false
LoginMode The connection mode. Can be one of the following:

- Windows, the Windows authentication will be used - SQLServer, the SQL Server authentication will be used - Predefined, the connection mode will be set according to the setting in the configuration file This parameter is used only if the Online parameter it set.

false false
Login The login name to connect to the SQL Server. If LoginMode is set to "Windows" or "Predefined", this parameter is ignored. This parameter is used only if the Online parameter it set. false false
Password The password to connect to the SQL Server. If LoginMode is set to "Windows" or "Predefined", this parameter is ignored. This parameter is used only if the Online parameter it set. false false
ConfigFile The configuration file name. The default configuration file is located at <%LocalAppData%>\Quest Software\Log Reader for SQL Server\QuestLogReader.config. You can use another configuration file.

If LoginMode is set to "Windows" or "SQLServer", this parameter is ignored. This parameter is used only if the Online parameter it set.

false false
LogBackup The addition transaction log backup files that will be loaded into the LogReader object. false false
Offline Set this parameter to read a transaction log from a database in offline state. true false
PrimaryDataFile The path to the primary database data file.

This parameter is used only if the Offline parameter it set.

true false
SecondaryFile The list of the secondary data and transaction log files. The file name may contain wildcard characters.

This parameter is used only if the Offline parameter it set.

true false
Backup Set this parameter to read a transaction log from a native or LiteSpeed backup file. true false
FullBackup The path to the full database backup file.

This parameter is used only if the Backup parameter it set.

true false

Return Values

Quest.LogReader.SqlServer.Wrappers.LogReaderSSWrapper

Notes

It is strongly recommend to close LogReader objects after you finish using it. Use the following commands:

   $lr = New-QLRSqlReader -Online
   ...
   $lr.Close()

Examples

EXAMPLE 1

$lr = New-QLRSqlReader –Online . Northwind Windows
Get-QLRSqlCommand $lr | more
$lr.Close()

These commands open the online transaction log for the Northwind database on the local server. Then all DML/DDL commands are read and the LogReader object is closed.

EXAMPLE 2

$lr = New-QLRSqlReader –Offline Z:\Data\Northwind.mdf Z:\Data\Northwind_log.ldf,Z:\Data\Northwind_log1.ldf
Get-QLRSqlCommand $lr | more
$lr.Close()

These commands open the transaction log for the offlined Northwind database with 2 log files. Then all DML/DDL commands are read and the LogReader object is closed.

EXAMPLE 3

$lr = New-QLRSqlReader –Backup Z:\Backups\Northwind_full.bak -LogBackup Z:\Backups\Northwind_log1.bak,Z:\Backups\Northwind_log2.bak
Get-QLRSqlCommand $lr | more
$lr.Close()

These commands open the full database backup of the Northwind database and attach 2 transaction log backup files. Then all DML/DDL commands are read and the LogReader object is closed.

EXAMPLE 4

$lr = New-QLRSqlReader –Online . Northwind Windows
Get-QLRSqlCommand $lr | Where-Object {$_.Type –eq “DML”} | more
$lr.Close()

These commands open the online transaction log for the Northwind database on the local server. Then all DML/DDL commands are filtered and only DML changes are written to the pipeline.

EXAMPLE 5

$lr = New-QLRSqlReader –Online . Northwind Windows
Get-QLRSqlCommand $lr | Where-Object {$_.ObjectName –eq “dbo.Customers”} | more
$lr.Close()

This example is similar to the example 4, but in this case only changes for dbo.Customers table are filtered out.

EXAMPLE 6

$lr = New-QLRSqlReader –Online . Northwind Windows
Get-QLRSqlCommand $lr | Where-Object {$_.Type –eq “DML”} | Out-QLRSqlXml C:\out.xml -Full
$lr.Close()

These commands open the online transaction log for the Northwind database on the local server. Then all DML/DDL commands are filtered to extract only DML changes. Result are exported into the C:\out.xml file in XML format.

Personal tools