|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, June 03, 2013 9:10 PM
Points: 27,
Visits: 360
|
|
Hi ,
Anyone help to script the linkedservers on weekly basis by automatically in text or .sql format file
Regards, Saran
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, June 14, 2013 9:58 AM
Points: 132,
Visits: 339
|
|
saranya.priyadharshini (3/21/2013) Hi ,
Anyone help to script the linkedservers on weekly basis by automatically in text or .sql format file
Regards, Saran
You may want to provide more detail I dont really understand what you want to achieve.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Today @ 11:06 AM
Points: 893,
Visits: 1,894
|
|
If you want to script out the linked server definitions, here is a powershell script that will accomplish this.
Add-PSSnapin SqlServerProviderSnapin100 Add-PSSnapin SqlServerCmdletSnapin100
$server="<servername>" $scriptpath="<path of script file>"
cd SQLSERVER:\SQL\$server\DEFAULT\LinkedServers
$Scripter=new-object ("Microsoft.SqlServer.Management.Smo.Scripter") ($server) $Scripter.Options.DriAll=$True $Scripter.Options.IncludeHeaders=$True $Scripter.Options.ToFileOnly=$True $Scripter.Options.WithDependencies=$False
foreach ($Item in Get-ChildItem) { $filename = $Item.ToString() $filename = $filename.Replace("\","_") $Scripter.Options.FileName=$scriptpath+$filename + ".sql" $Scripter.Options.AppendToFile=$False $Scripter.Options.ScriptDrops=$True; $Scripter.Options.IncludeIfNotExists=$True; $Scripter.Script($Item) $Scripter.Options.ScriptDrops=$False; $Scripter.Options.IncludeIfNotExists=$False; $Scripter.Options.AppendToFile=$True $Scripter.Script($Item) }
Bob ----------------------------------------------------------------------------- http://www.sqlservercentral.com/articles/Best+Practices/61537/
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, June 03, 2013 9:10 PM
Points: 27,
Visits: 360
|
|
Receiving an Errror.. Its not working
|
|
|
|