小编nic*_*ick的帖子

如何在sql脚本中指定"关闭现有连接"

我正在SQL Server 2008中对我的架构进行主动开发,并经常要重新运行我的drop/create数据库脚本.我跑的时候

USE [master]
GO

IF  EXISTS (SELECT name FROM sys.databases WHERE name = N'MyDatabase')
DROP DATABASE [MyDatabase]
GO
Run Code Online (Sandbox Code Playgroud)

我经常遇到这个错误

Msg 3702, Level 16, State 4, Line 3
Cannot drop database "MyDatabase" because it is currently in use.
Run Code Online (Sandbox Code Playgroud)

如果右键单击对象资源管理器窗格中的数据库并从上下文菜单中选择"删除"任务,则会出现一个"关闭现有连接"的复选框

有没有办法在我的脚本中指定此选项?

sql sql-server

145
推荐指数
4
解决办法
10万
查看次数

我可以在powershell中使用System.Core.dll/System.Collections.Generic.HashSet吗?

我想在powershell脚本中使用HashSet.我想我已经弄清楚如何通过执行以下方式实例化通用集合对象:

[type] $strType = "string"
$listClass = [System.Collections.Generic.List``1]
$listObject = $base.MakeGenericType(@($t))
$myList = New-Object $setObject
Run Code Online (Sandbox Code Playgroud)

这适用于列表和词典,但是当我尝试创建HashSet时,我得到:

Unable to find type [System.Collections.Generic.HashSet`1]: make sure that the assembly containing this type is loaded.
Run Code Online (Sandbox Code Playgroud)

所以看起来我现在需要加载System.Core.dll但我似乎无法使用powershell加载该程序集.例如,调用[System.Reflection.Assembly] :: LoadWithPartialName("System.Core")会导致此异常:

"LoadWithPartialName" with "1" argument(s): "Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified."
Run Code Online (Sandbox Code Playgroud)

有什么指针吗?

.net powershell .net-3.5

12
推荐指数
1
解决办法
6841
查看次数

如何阻止windbg成为交互式调试器?

在vista/win7上撤消windbg -I的正确方法是什么?

是否像删除HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug中的注册表项一样简单?

windbg

11
推荐指数
1
解决办法
8701
查看次数

标签 统计

.net ×1

.net-3.5 ×1

powershell ×1

sql ×1

sql-server ×1

windbg ×1