SqlServer:SqlServer(服务器磁盘监控,创建管理员账号分配权,添加链接服务器,查询CPU,查询内存)
1.服务器磁盘监控
(1)总链接服务上开启所有链接服务器的RPC:
----------------------总链接服务器上面,开启每个服务器的RPC
--exec sp_serveroption @server='S32' , @optname= 'rpc', @optvalue ='TRUE' --exec sp_serveroption @server='S32' , @optname= 'rpc out', @optvalue='TRUE' SELECT 'exec sp_serveroption @server= '''+ name+''' , @optname= ''rpc'',@optvalue =''TRUE'' ' FROM sys.servers
ORDER BY name
SELECT 'exec sp_serveroption @server= '''+ name+''' , @optname= ''rpc out'',@optvalue =''TRUE'' ' FROM sys.servers
ORDER BY name
(2)各个服务上创建监测(根据本地情况,需要改总链接服务器IP和本机IP):
------添加链接服务器
IF NOT EXISTS (SELECT 1 FROM sys.servers WHERE name like '%100.80.10.30%')
BEGIN
EXEC master.dbo.sp_addlinkedserver
--服务器名称
@server = '100.80.10.30', --36-48,12-15,
@srvproduct = N'', @provider = 'SQLOLEDB',
--IP
@datasrc = '100.80.10.30';
EXEC master.dbo.sp_addlinkedsrvlogin --IP
'100.80.10.30', false, NULL, --账号
'sa', --密码
'hnsjt_lwsj@2018';
END;
GO CREATE DATABASE [monitor];
GO
USE [monitor];
GO
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
-- =============================================
-- Author: <Author,,Name> k
-- Create date: <Create Date,,>20190218
-- Description: <Description,,>监控磁盘使用情况
-- ============================================= CREATE PROCEDURE disk_monitor
AS
BEGIN SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; --创建相关表
IF OBJECT_ID('tempdb..#server_disk_usage') IS NULL
BEGIN
CREATE TABLE #server_disk_usage
(
[ip] [NVARCHAR](400) ,
[disk_num] [NVARCHAR](10) NOT NULL ,
[total_size_mb] [BIGINT]
NOT NULL
CONSTRAINT [DF_#server_disk_usage_total_size_mb]
DEFAULT ( (0) ) ,
[free_siez_mb] [BIGINT]
NOT NULL
CONSTRAINT [DF_#server_disk_usage_free_siez_mb]
DEFAULT ( (0) ) ,
[disk_info] [NVARCHAR](400)
NOT NULL
CONSTRAINT [DF_#server_disk_usage_disk_info]
DEFAULT ( '' ) ,
[iswarning] [NVARCHAR](400) ,
[check_time] [DATETIME]
NOT NULL
CONSTRAINT [DF_#server_disk_usage_check_time]
DEFAULT ( GETDATE() ) ,
CONSTRAINT [PK_#server_disk_usage] PRIMARY KEY CLUSTERED
( [disk_num] ASC )
)
ON [PRIMARY];
END; --==========================================
--查看所有数据库使用到的磁盘剩余空间
DECLARE @disk TABLE
(
[disk_num] VARCHAR(50) ,
[free_siez_mb] INT
);
INSERT INTO @disk
EXEC xp_fixeddrives; --更新当前磁盘的剩余空间信息
UPDATE M
SET M.[free_siez_mb] = D.[free_siez_mb]
FROM #server_disk_usage AS M
INNER JOIN @disk AS D ON M.[disk_num] = D.[disk_num]; --插入新增磁盘的剩余空间信息
INSERT INTO #server_disk_usage
( [disk_num] ,
[free_siez_mb]
)
SELECT [disk_num] ,
[free_siez_mb]
FROM @disk AS D
WHERE NOT EXISTS ( SELECT 1
FROM #server_disk_usage AS M
WHERE M.[disk_num] = D.[disk_num] ); -------------------------------------------------------2 --开启CMDShell
EXEC sp_configure 'show advanced options', 1; RECONFIGURE WITH OVERRIDE; EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE WITH OVERRIDE; --========================================
--创建临时表用来存放每个盘符的数据
CREATE TABLE #tempDisks
(
ID INT IDENTITY(1, 1) ,
DiskSpace NVARCHAR(200)
);
--============================================
--将需要检查的磁盘放入临时表#checkDisks
SELECT ROW_NUMBER() OVER ( ORDER BY [disk_num] ) AS RID ,
[disk_num]
INTO #checkDisks
FROM #server_disk_usage
WHERE [total_size_mb] = 0; --============================================
--循环临时表#checkDisks检查每个磁盘的总量 DECLARE @disk_num NVARCHAR(20);
DECLARE @total_size_mb INT;
DECLARE @sql NVARCHAR(200);
DECLARE @max INT;
DECLARE @min INT;
SELECT @max = MAX(RID) ,
@min = MIN(RID)
FROM #checkDisks; WHILE ( @min <= @max )
BEGIN
SELECT @disk_num = [disk_num]
FROM #checkDisks
WHERE RID = @min; SET @sql = N'EXEC sys.xp_cmdshell ''fsutil volume diskfree '
+ @disk_num + ':' + '''';
PRINT @sql; INSERT INTO #tempDisks
EXEC ( @sql
); SELECT @total_size_mb = CAST(( RIGHT(DiskSpace,
LEN(DiskSpace)
- CHARINDEX(': ',
DiskSpace) - 1) ) AS BIGINT)
/ 1024 / 1024
FROM #tempDisks
WHERE ID = 2; --SELECT @total_size_mb,@disk_num UPDATE #server_disk_usage
SET [total_size_mb] = @total_size_mb
WHERE [disk_num] = @disk_num; --SELECT * FROM #tempDisks TRUNCATE TABLE #tempDisks; SET @min = @min + 1; END; --==========================================
--CMDShell EXEC sp_configure 'xp_cmdshell', 0; EXEC sp_configure 'show advanced options', 1; RECONFIGURE WITH OVERRIDE; DELETE FROM [100.80.10.30].[monitor].[dbo].[server_disk_usage]
WHERE CONVERT(VARCHAR, check_time, 23) = CONVERT(VARCHAR, GETDATE(), 23)
AND ip = '100.80.10.48';
INSERT INTO [100.80.10.30].[monitor].[dbo].[server_disk_usage]
SELECT '100.80.10.48' AS IP ,
[disk_num] AS Drive_Name ,
CAST([total_size_mb] / 1024.0 AS NUMERIC(18, 2)) AS Total_Space_GB ,
CAST(( [total_size_mb] - [free_siez_mb] ) / 1024.0 AS NUMERIC(18,
2)) AS Used_Space_GB ,
CAST([free_siez_mb] / 1024.0 AS NUMERIC(18, 2)) AS Free_Space_GB ,
CAST([free_siez_mb] * 100 / [total_size_mb] AS NUMERIC(18,
2)) AS Free_Space_Percent ,
[disk_info] ,
[check_time]
FROM #server_disk_usage; DROP TABLE #server_disk_usage; END;
GO
(3)总链接服务器创建监测:
CREATE DATABASE [monitor];
GO
USE [monitor];
GO
/****** Object: StoredProcedure [dbo].[get_disk_use_info] Script Date: 02/19/2019 09:46:23 ******/
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
-- =============================================
-- Author: <Author,,Name> k
-- Create date: <Create Date,,>20190218
-- Description: <Description,,>监控磁盘使用情况
-- =============================================
CREATE PROCEDURE [dbo].[get_disk_use_info]
AS
BEGIN SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
--******************************************************
--******************************************************
IF OBJECT_ID('server_disk_usage') IS NOT NULL
BEGIN
DROP TABLE server_disk_usage;
END; --==========================================
--创建相关表
IF OBJECT_ID('tempdb..#server_disk_usage') IS NULL
BEGIN
CREATE TABLE #server_disk_usage
(
[disk_num] [NVARCHAR](10) NOT NULL ,
[total_size_mb] [BIGINT]
NOT NULL
CONSTRAINT [DF_#server_disk_usage_total_size_mb]
DEFAULT ( (0) ) ,
[free_siez_mb] [BIGINT]
NOT NULL
CONSTRAINT [DF_#server_disk_usage_free_siez_mb]
DEFAULT ( (0) ) ,
[disk_info] [NVARCHAR](400)
NOT NULL
CONSTRAINT [DF_#server_disk_usage_disk_info]
DEFAULT ( '' ) ,
[check_time] [DATETIME]
NOT NULL
CONSTRAINT [DF_#server_disk_usage_check_time]
DEFAULT ( GETDATE() ) ,
CONSTRAINT [PK_#server_disk_usage] PRIMARY KEY CLUSTERED
( [disk_num] ASC )
)
ON [PRIMARY];
END; --==========================================
--查看所有数据库使用到的磁盘剩余空间
DECLARE @disk TABLE
(
[disk_num] VARCHAR(50) ,
[free_siez_mb] INT
);
INSERT INTO @disk
EXEC xp_fixeddrives; --更新当前磁盘的剩余空间信息
UPDATE M
SET M.[free_siez_mb] = D.[free_siez_mb]
FROM #server_disk_usage AS M
INNER JOIN @disk AS D ON M.[disk_num] = D.[disk_num]; --插入新增磁盘的剩余空间信息
INSERT INTO #server_disk_usage
( [disk_num] ,
[free_siez_mb]
)
SELECT [disk_num] ,
[free_siez_mb]
FROM @disk AS D
WHERE NOT EXISTS ( SELECT 1
FROM #server_disk_usage AS M
WHERE M.[disk_num] = D.[disk_num] ); -------------------------------------------------------2 --开启CMDShell
EXEC sp_configure 'show advanced options', 1; RECONFIGURE WITH OVERRIDE; EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE WITH OVERRIDE; --========================================
--创建临时表用来存放每个盘符的数据
CREATE TABLE #tempDisks
(
ID INT IDENTITY(1, 1) ,
DiskSpace NVARCHAR(200)
);
--============================================
--将需要检查的磁盘放入临时表#checkDisks
SELECT ROW_NUMBER() OVER ( ORDER BY [disk_num] ) AS RID ,
[disk_num]
INTO #checkDisks
FROM #server_disk_usage
WHERE [total_size_mb] = 0; --============================================
--循环临时表#checkDisks检查每个磁盘的总量 DECLARE @disk_num NVARCHAR(20);
DECLARE @total_size_mb INT;
DECLARE @sql NVARCHAR(200);
DECLARE @max INT;
DECLARE @min INT;
SELECT @max = MAX(RID) ,
@min = MIN(RID)
FROM #checkDisks; WHILE ( @min <= @max )
BEGIN
SELECT @disk_num = [disk_num]
FROM #checkDisks
WHERE RID = @min; SET @sql = N'EXEC sys.xp_cmdshell ''fsutil volume diskfree '
+ @disk_num + ':' + '''';
PRINT @sql; INSERT INTO #tempDisks
EXEC ( @sql
); SELECT @total_size_mb = CAST(( RIGHT(DiskSpace,
LEN(DiskSpace)
- CHARINDEX(': ',
DiskSpace) - 1) ) AS BIGINT)
/ 1024 / 1024
FROM #tempDisks
WHERE ID = 2; --SELECT @total_size_mb,@disk_num UPDATE #server_disk_usage
SET [total_size_mb] = @total_size_mb
WHERE [disk_num] = @disk_num; --SELECT * FROM #tempDisks TRUNCATE TABLE #tempDisks; SET @min = @min + 1; END; --==========================================
--CMDShell EXEC sp_configure 'xp_cmdshell', 0; EXEC sp_configure 'show advanced options', 1; RECONFIGURE WITH OVERRIDE; IF OBJECT_ID('server_disk_usage') IS NULL
BEGIN
CREATE TABLE server_disk_usage
(
ip VARCHAR(200) ,
Drive_Name VARCHAR(200) ,
Total_Space_GB VARCHAR(200) ,
Used_Space_GB VARCHAR(200) ,
Free_Space_GB VARCHAR(200) ,
Free_Space_Percent VARCHAR(200) ,
[disk_info] VARCHAR(200) ,
[check_time] DATETIME
);
END; INSERT INTO [server_disk_usage]
SELECT '100.80.10.30' AS IP ,
[disk_num] AS Drive_Name ,
CAST([total_size_mb] / 1024.0 AS NUMERIC(18, 2)) AS Total_Space_GB ,
CAST(( [total_size_mb] - [free_siez_mb] ) / 1024.0 AS NUMERIC(18,
2)) AS Used_Space_GB ,
CAST([free_siez_mb] / 1024.0 AS NUMERIC(18, 2)) AS Free_Space_GB ,
CAST([free_siez_mb] * 100 / [total_size_mb] AS NUMERIC(18,
2)) AS Free_Space_Percent ,
[disk_info] ,
[check_time]
FROM #server_disk_usage; DROP TABLE #server_disk_usage; END;
(4)在总链接服务器上创建调用的存储过程,调用各个服务器上的监控,更新各个服务器磁盘使用情况,存放至 [NETWORKING_AUDIT] 库的T_DISK_MONITOR表
-- =============================================
-- Author: k
-- Create date: 20190219
-- Description: 更新各个服务器磁盘使用情况,存放至T_DISK_MONITOR表
-- =============================================
ALTER PROCEDURE [dbo].[updateDiskMonitorInfo] AS
BEGIN
-------------调用各个服务器上的监控
EXEC [monitor].[dbo].[get_disk_use_info]
DECLARE @ServerName VARCHAR(255);
DECLARE @sql VARCHAR(8000);
DECLARE cur CURSOR
FOR
SELECT name FROM sys.servers
WHERE name !='WIN-4AAGSGNR81A'
OPEN cur;
FETCH NEXT FROM cur INTO @ServerName;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @sql = 'EXEC ['+@ServerName+'].[monitor]..[disk_monitor];'
EXEC (@sql);
FETCH NEXT FROM cur INTO @ServerName; END;
CLOSE cur;
DEALLOCATE cur; -------------将磁盘使用情况存放至系统库[NETWORKING_AUDIT]
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'T_DISK_MONITOR')
BEGIN
DROP TABLE [NETWORKING_AUDIT].[dbo].[T_DISK_MONITOR];
END
SELECT * INTO [NETWORKING_AUDIT].[dbo].[T_DISK_MONITOR]
from [monitor].[dbo].[server_disk_usage]
ORDER BY ip END
(5)创建SQLSERVER定时作业,每天自动更新即可
如图:
2.创建管理员账号分配权限
(1)基本语法:
--查看数据库schema, user 的存储过程
select * from sys.database_principals
select * from sys.schemas
select * from sys.server_principals
select * from sysusers
select * from sys.syslogins --创建登陆帐户(create login)
create login dba with password='abcd1234@', default_database=mydb --为登陆账户创建数据库用户(create user),在mydb数据库中的security中的user下可以找到新创建的dba
create user dba for login dba with default_schema=dbo --通过加入数据库角色,赋予数据库用户“db_owner”权限
exec sp_addrolemember 'db_owner', 'dba' --让 SQL Server 登陆帐户“dba”访问多个数据库
use mydb2
go create user dba for login dba with default_schema=dbo
go exec sp_addrolemember 'db_owner', 'dba'go --禁用登陆帐户
alter login dba disable
--启用登陆帐户
alter login dba enable
--登陆帐户改名
alter login dba with name=dba_tom
--登陆帐户改密码:
alter login dba with password='aabb@ccdd'
--数据库用户改名:
alter user dba with name=dba_tom
--更改数据库用户 defult_schema:
alter user dba with default_schema=sales
--删除数据库用户:
drop user dba
--删除 SQL Server登陆帐户:
drop login dba --创建角色 r_test
EXEC sp_addrole 'r_test' --添加登录 l_test,设置密码为pwd,默认数据库为pubs
EXEC sp_addlogin 'l_test','a@cd123','InsideTSQL2008' --为登录 l_test 在数据库 pubs 中添加安全账户 u_test
EXEC sp_grantdbaccess 'l_test','u_test' --添加 u_test 为角色 r_test 的成员
EXEC sp_addrolemember 'r_test','u_test' --用l_test登陆,发现在SSMS中找不到仍和表,因此执行下述两条语句出错。
select * from Sales.Orders
select * from HR.Employees --授予角色 r_test 对 HR.Employees 表的所有权限
GRANT ALL ON HR.Employees TO r_test
--The ALL permission is deprecated and maintained only for compatibility.
--It DOES NOT imply ALL permissions defined on the entity.
--ALL 权限已不再推荐使用,并且只保留用于兼容性目的。它并不表示对实体定义了 ALL 权限。 --测试可以查询表HR.Employees,但是Sales.Orders无法查询
select * from HR.Employees --如果要收回权限,可以使用如下语句。(可选择执行)
revoke all on HR.Employees from r_test
--ALL 权限已不再推荐使用,并且只保留用于兼容性目的。它并不表示对实体定义了 ALL 权限。 --授予角色 r_test 对 Sales.Orders 表的 SELECT 权限
GRANT SELECT ON Sales.Orders TO r_test --用l_test登陆,发现可以查询Sales.Orders和HR.Employees两张表
select * from Sales.Orders
select * from HR.Employees --拒绝安全账户 u_test 对 HR.Employees 表的 SELECT 权限
DENY SELECT ON HR.Employees TO u_test --再次执行查询HR.Employees表的语句,提示:拒绝了对对象 'Employees' (数据库 'InsideTSQL2008',架构 'HR')的 SELECT 权限。
select * from HR.Employees --重新授权
GRANT SELECT ON HR.Employees TO u_test --再次查询,可以查询出结果。
select * from HR.Employees USE InsideTSQL2008
--从数据库中删除安全账户,failed
EXEC sp_revokedbaccess 'u_test'
--删除角色 r_test,failed
EXEC sp_droprole 'r_test'
--删除登录 l_test,success
EXEC sp_droplogin 'l_test'
(2)创建管理员用户和创建只读用户
--******************创建管理员账号******************--
--**************************************************--
USE master
Go
--创建登陆帐户(create login)
create login lwsjbackgr with password='hnsjt_lwsj@2019', default_database=master --为登陆账户创建数据库用户(create user),在mydb数据库中的security中的user下可以找到新创建的dba
create user lwsjbackgr for login lwsjbackgr with default_schema=dbo --添加服务器角色
EXEC master.dbo.sp_addsrvrolemember @loginame = N'lwsjbackgr', @rolename = N'sysadmin' --添加数据库角色
--use [国土资源厅]
--create user sread for login sread with default_schema=dbo
--此处分配只读
--exec sp_addrolemember 'db_datareader', 'sread' --禁用sa账号
alter login sa DISABLE --******************创建只读权限账号****************--
--**************************************************-- --------------------------强制中断连接中的数据库
CREATE TABLE #temt(spid NVARCHAR(max),
ecid NVARCHAR(max),
status NVARCHAR(max),
logname NVARCHAR(max),
hostname NVARCHAR(max),
blk NVARCHAR(max),
dbname NVARCHAR(max),
cmd NVARCHAR(max),
request_id NVARCHAR(max)
)
INSERT INTO #temt
exec sp_who IF EXISTS(SELECT 1 FROM #temt WHERE logname = 'sread')
BEGIN
DECLARE @spid NVARCHAR(200)
DECLARE @ksql NVARCHAR(200)
DECLARE cur CURSOR
FOR
SELECT spid FROM #temt WHERE logname = 'sread'
OPEN cur;
FETCH NEXT FROM cur INTO @spid;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @ksql = 'KILL '+@spid
EXEC (@ksql)
FETCH NEXT FROM cur INTO @spid;
END;
CLOSE cur;
DEALLOCATE cur;
END
DROP TABLE #temt --------------------------删除只读用户
IF EXISTS(Select 1 FROM sys.sysusers WHERE name ='sread')
BEGIN
DROP USER sread
END
IF EXISTS(Select 1 FROM sys.syslogins WHERE name ='sread')
BEGIN
DROP LOGIN sread
END --创建只读用户(create login)
create login sread with password='hnsjt_123456', default_database=master --为只读用户创建数据库用户(create user),在mydb数据库中的security中的user下可以找到新创建的dba
create user sread for login sread with default_schema=dbo --------------------------每个数据库添加只读权限角色 DECLARE @DatabaseName VARCHAR(255);
DECLARE @user VARCHAR(255);
SET @user = 'sread'
DECLARE @sql VARCHAR(8000);
DECLARE cur CURSOR
FOR
SELECT name FROM sys.databases OPEN cur;
FETCH NEXT FROM cur INTO @DatabaseName;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @sql = 'USE ['+@DatabaseName+']
IF EXISTS(Select 1 FROM sys.sysusers WHERE name = '''+@user+''')
BEGIN
EXEC sp_revokedbaccess '''+@user+'''
END
create user '+@user+' for login '+@user+' with default_schema=dbo
EXEC sp_addrolemember ''db_datareader'','''+@user+'''
'
EXEC (@sql);
FETCH NEXT FROM cur INTO @DatabaseName; END;
CLOSE cur;
DEALLOCATE cur;
3.添加链接服务器
------查询现有链接服务器状态
SELECT * FROM SYS.servers --创删除远程链接服务器 --删除运行本地与远程之间的用户映射
execute sys.sp_droplinkedsrvlogin @rmtsrvname='100.80.10.30',@locallogin=null
--删除链接服务器
execute sys.sp_dropserver @server='100.80.10.30',@droplogins='droplogins' --添加远程链接服务器 --创建远程链接服务器
execute sys.sp_addlinkedserver @server='100.80.10.30', --被访问的服务器别名
@srvproduct='',
@provider='SQLOLEDB',
@datasrc='100.80.10.30' --被访问的服务器地址(IP地址,端口号\服务器名称)
--创建本地用户与远程服务器中用户之间的映射
execute sys.sp_addlinkedsrvlogin @rmtsrvname='100.80.10.30', --被访问的服务器别名
@useself='false', --是否通过模拟本地登录名或显式提交登录名和密码来连接到远程服务器
@locallogin=null, --本地登录
@rmtuser='lwsjbackgr', --用户名
@rmtpassword='hnsjt_lwsjdb@2019' --密码
go
4.查询CPU
DECLARE @ts_now bigint
set @ts_now = (SELECT cpu_ticks/(cpu_ticks/ms_ticks)
FROM master.sys.dm_os_sys_info WITH (NOLOCK));
SELECT
DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] ,
SQLProcessUtilization AS [SQL Server Process CPU Utilization],
SystemIdle AS [System Idle Process],
(100 - SystemIdle - SQLProcessUtilization) AS [Other Process CPU Utilization]
FROM (
SELECT
record.value('(./Record/@id)[1]', 'int') AS record_id,
record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS [SystemIdle],
record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]','int') AS [SQLProcessUtilization],
[timestamp]
FROM (
SELECT [timestamp], CONVERT(xml, record) AS [record]
FROM master.sys.dm_os_ring_buffers
WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR'
AND record LIKE N'%%') AS x
) AS y
ORDER BY record_id DESC;
5.查询内存
SELECT total_physical_memory_kb / 1024 AS [物理内存(MB)] ,
available_physical_memory_kb / 1024 AS [可用物理内存(MB)] ,
system_cache_kb / 1024 AS [系统缓存内存总量(MB)] ,
( kernel_paged_pool_kb + kernel_nonpaged_pool_kb ) / 1024 AS [内核池内存总量(MB)] ,
total_page_file_kb / 1024 AS [操作系统报告的提交限制的大小(MB)] ,
available_page_file_kb / 1024 AS [未使用的页文件的总量(MB)] ,
system_memory_state_desc AS [内存状态说明]
FROM sys.dm_os_sys_memory
SqlServer:SqlServer(服务器磁盘监控,创建管理员账号分配权,添加链接服务器,查询CPU,查询内存)的更多相关文章
- sqlserver 多库查询 sp_addlinkedserver使用方法(添加链接服务器)
sqlserver 多库查询 sp_addlinkedserver使用方法(添加链接服务器) 我们日常使用SQL Server数据库时,经常遇到需要在实例Instance01中跨实例访问Instanc ...
- SQLServer添加链接服务器
右键,添加链接服务器 在安全里面输入用户名和密码 添加成功之后的使用方法 select * from [192.168.1.63,3326].[数据库].[dbo].[表]
- Django创建管理员账号
python manage.py createsuperuser 创建一个管理员账号 输入账号:admin 输入邮箱:123456789@qq.com 输入密码:test123456 二次确认 pyt ...
- SQL Server 添加链接服务器
背景 在SQL SERVER中,如果我们查询数据库需要关联另外一台数据库中表,在这种情况下我们可以通过添加服务器链接来实现. 案列 方式1.sql server 提供了图形化界面,如下: 右键> ...
- 添加链接服务器 SQL SERVER
使用sql语句: exec sp_addlinkedserver @server='serverontest',@provider='sqloledb',@srvproduct='',@datasrc ...
- SQL server添加链接服务器脚本
---恢复内容开始--- exec sp_addlinkedserver 'ZZSJK','','SQLOLEDB','192.168.10.22' --链接服务器名称 ‘’ ip地址exec s ...
- sql server通过脚本添加链接服务器
exec sp_addlinkedserver 'ZZSJK','','SQLOLEDB','192.168.10.22' --链接服务器名称 ‘’ ip地址exec sp_addlinkedsr ...
- MacOS修改用户名后变为普通用户,无法创建管理员账号
摘要:有的时候用户修改原电脑用户名,会把该用户降为普通用户,点击下方的锁会弹出下方图示,导致无法修改任何设置 解决方案: 重启电脑Restart按Command+S进入终端terminal输入以下命令 ...
- K8S 创建管理员账号
一.生成管理员证书 cat > admin-csr.json <<EOF { "CN": "admin", "hosts" ...
随机推荐
- 1.安装Loucust
python 3.x 通过pip安装: pip install locustio 如果是以分布式队列运行locust,需要装一种通信队列的库pyzmq :pip install pyzmq 安装成功 ...
- P5657 格雷码
思路 考场上的递归思路 每次向下递归的时候判断是左半边还是右半边即可 注意向右半边递归之后下一层序列要反转过来即可 代码 #include <cstdio> #include <al ...
- C# 集合(9) 持续更新
数组的大小是固定的.如果元素个数动态,就使用集合类. List<T>是与数组相当的集合类.其他的集合:队列.栈.链表.字典和集. .NET Framework 1.0 包括非泛型集合类,如 ...
- ACM-ICPC 2016 沈阳赛区现场赛 I. The Elder && HDU 5956(斜率DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5956 题意:一颗树上每条边有个权值,每个节点都有新闻要送到根节点就是1节点,运送过程中如果不换青蛙就是 ...
- springboot2.0入门(一)----springboot 简介
一.springboot解决了什么? 避免了繁杂的xml配置,框架自动帮我们完成了相关的配置,当我们需要进行相关插件集成的时候,只需要将相关的starter通过相关的maven依赖引进,并可以进行相关 ...
- MULTIPOLYGON、POLYGON 封装为echart geoJson 数据封装
一.环境.问题简述: 1.采用的事前后端分离,后端需要封装将点位获取的点位信息封装为geoJson数据类型,供前端利用echart 绘制地图: 2.思路:简单理解geoJson,将对应坐标点位封装为g ...
- 传统Spring配置JTA 实现多数据源事务的统一管理
分布式事务是指事务的参与者.支持事务的服务器.资源管理器以及事务管理器分别位于分布系统的不同节点之上,在两个或多个网络计算机资源上访问并且更新数据,将两个或多个网络计算机的数据进行的多次操作作为一个整 ...
- @Test 测试
package com.自定义.mall.admin.system; import java.util.List; import java.util.Map; import javax.annotat ...
- HDU 5734 Acperience ( 数学公式推导、一元二次方程 )
题目链接 题意 : 给出 n 维向量 W.要你构造一个 n 维向量 B = ( b1.b2.b3 ..... ) ( bi ∈ { +1, -1 } ) .然后求出对于一个常数 α > 0 使得 ...
- 阿里云Ubuntu安装Composer和中国镜像
引用: Composer是PHP用来管理依赖(dependency)关系的工具.你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer 会帮你安装这些依赖的库文件. PHP ...