select * from sp_who的解决方案
发布时间:2024-01-15 09:55:52
方法一:使用临时表。
首先创建一个与sp_who相同字段的临时,然后用insert into 方法赋值,这样就可以select这个临时表了。具体代码如下:
create table #TempTable(spid int,ecid int,status varchar(32),loginname varchar(32),hostname varchar(32),blk int,dbname varchar(32),cmd varchar(32),request_id int);
insert into #TempTable
exec sp_who;
select * from #TempTable where [dbname] = 'master';
drop table #TempTable
方法二:使用OPENROWSET
代码如下:
select * from openrowset('SQLOLEDB','servername';'userName';'password','sp_who') where [dbname] = 'master';
执行上面这个语句,如果提示:SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息。
说明你没有配置 'Ad Hoc Distributed Queries' ,按如下方法配置
启用Ad Hoc Distributed Queries:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
然后就可以运行上面的代码了。
使用完成后,如果想关闭Ad Hoc Distributed Queries,执行如下代码:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
猜你喜欢
- 什么是 AOPAOP,就是面向切面编程,简单的说,就是动态地将代码切入到类的指定方法、指定位置上的编程思想就是面向切面的编程。我们管切入到指
- 本文实例讲述了Python3.5变量、数据结构、条件和循环语句、break与continue语句。分享给大家供大家参考,具体如下:1、变量:
- 场景在 Go 语言中,常量分为有类型常量和无类型常量。// 有类型常量const VERSION string = "v1.0.0
- 一、简介从Python2.6开始,新增了str.format(),它增强了字符串格式化的功能。基本语法是通过 {} 和 : 来代替以前的 %
- 一、效果展示1、俄罗斯方块这个应该是玩起来最最简单的了…2、扫雷运气好,点了四下都没踩雷哈哈…3、五子棋我是菜鸡,玩不赢电脑人…
- home.html:<!DOCTYPE html><html lang="en"><hea
- 大家还好吗?背景就不用多说了吧?本来我是初四上班的,现在延长到2月10日了。这是我工作以来时间最长的一个假期了。可惜哪也去不了。待在家里,没
- 学习目标:学会使用windows系统安装MySQL数据库,供大家参考,具体内容如下1.打开浏览器输入SQL官网的下载地址:下载链接2.下载好
- 这段时间服务器崩溃2次,一直没有找到原因,今天看到论坛发出的错误信息邮件,想起可能是MySQL的默认连接数引起的问题,一查果然,老天,默认
- Instr函数与InstrRev函数大家都应该很熟悉,但是如果你看过《ASP * 站开发实践教程》,你应该注意一下。该书中介绍它们时是很有迷
- Numpy学习1 Numpy 介绍与应用1-1Numpy是什么NumPy 是一个运行速度非常快的数学库,一个开源的的python科学计算库,
- 导语嘿!下午好,木子来上新啦~期待今天的内容嘛?挠头.jpg 日常等更新的小可爱们我来了。看看给大家带来了什么好东西💦💦💦💦💦💦💦💦💦💦💦💦
- 打开文件import xlrddata = xlrd.open_workbook('路径')获取文件中所有工作表的名称。da
- 介绍本文主要介绍Python中迭代的基本知识和使用什么是迭代在Python中,如果给定一个list或tuple,我们可以通过for循环来遍历
- 看代码吧~func remove(slice []interface{}, elem interface{}) []interface{}{
- 粘包问题TCP协议在传输过程中会出现数据粘包问题讲一下TCP和UDP的区别,都是传数据的协议,没有好坏之说,只是不同的应用需求可能会更好选择
- 相信大家都想把自己完成的项目打包成EXE应用文件,然后就可以放在桌面随时都能运行了,下面来分享利用pytinstaller这个第三方库来打包
- 之前用Vue+element写了一个后台管理系统,在登录时使用axios请求数据传参时无法正常的获取数据。之后也是一通百度,发现原因是传递参
- 那你也许会问及,怎样获取当前系统日期的最大时间值,如yyyy-MM-dd 23:59:59.997。 我们可以使用DATEADD函数,来实现
- 1.如何用函数先定义后调用,定义阶段只检测语法,不执行代码调用阶段,开始执行代码函数都有返回值定义时无参,调用时也是无参定义时有参,调用时也