使用Invoke-Sqlcmd在Powershell中删除数据库会告诉我数据库正在使用中,即使数据库没有使用

时间:2018-07-19 15:17:03

标签: powershell invoke-sqlcmd

我正在尝试删除这样的数据库

import skimage.data
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors

cmapgrn = matplotlib.colors.LinearSegmentedColormap.from_list("", ["black", "seagreen"])
cmapred = matplotlib.colors.LinearSegmentedColormap.from_list("", ["black", "red"])


fig, ax = plt.subplots(nrows = 1, ncols = 3, figsize = (10,5))
ax = ax.ravel()

multichannel = skimage.data.hubble_deep_field() # type: np.ndarray

green_raw = multichannel[:200, :200, 0]   # type: np.ndarray
red_raw   = multichannel[:200, :200, 1].T # type: np.ndarray

imgs = green_raw, red_raw

all_imgs = []
for img in imgs:
    img_rescale = img/img.max()
    all_imgs.append(img_rescale)

green, red = all_imgs # type: np.ndarray

G = green
R = red

cmin = 0.0
cmax = 0.5

def rescale(arr: np.ndarray):
    re = (arr - arr.min()) / (arr.max() - arr.min())
    return re


def blend(image1, image2, cmap1, cmap2):
    a = cmap1(image1)
    b = cmap2(image2)

    screen = 1 - (1 - a) * (1 - b)
    return screen


G_r = rescale(G.clip(cmin, cmax))
R_r = rescale(R.clip(cmin, cmax))

ax[0].imshow(G_r, cmap = cmapgrn)
ax[1].imshow(R_r, cmap = cmapred)
ax[2].imshow(blend(image1 = G_r,
                   image2 = R_r,
                   cmap1 = cmapgrn,
                   cmap2 = cmapred))

plt.tight_layout()
plt.show()

在powershell脚本中,我收到此消息:

Invoke-Sqlcmd -Database Dbname-ServerInstance ".\SQLEXPRESS" -Query "drop database DbName;"

数据库未使用。我在做什么错了?

1 个答案:

答案 0 :(得分:0)

数据库正在使用中-您已连接到数据库!尝试-Database master。 – Jeroen Mostert