开发者

How do I use Powershell to detach a SQL Server database?

I am sure that this can be achieved by loading the SQL Server Management Objects assemblies but I am curious as to whether the 'Start Powershell' item in 开发者_高级运维the context menu within SQL Server Management Studio 2008 will give me a headstart.


The SMO Server class has a DetachDatabase method that you can use from Start PowerShell. From the server level in sqlps you can use something like this:

PS SQLSERVER:\SQL\Z002>get-childitem | foreach{$_.DetachDatabase("pubs",$false)}

See the MSDN docs for detailed info on DetachDatabase:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜