SQL Server 의 확장 저장 프로시저
--1.
execute master..xp_getnetname
--
select SERVERPROPERTY('MachineName')
--
select @@SERVERNAME
--2.
if exists(select 1 from sys.tables where name = 'errorLog')
begin
drop table errorLog
end
create table errorLog
(
LogDate datetime,
ProcessInfo nvarchar(20),
Text nvarchar(max)
)
insert into errorlog
exec master.sys.sp_readerrorlog
select *
from errorLog
-- xp_ReadErrorLog
-- sys.xp_ReadErrorLog master.dbo.xp_ReadErrorLog
select *
from sys.all_sql_modules
where definition like '%sys.xp_ReadErrorLog%'
/*===================================================
, 6 ,
, :6~99 。
@p1, ,
:
0: ,
1: 1
2: 2
3: 3
4: 4
5: 5
6: 6
=====================================================*/
exec master.dbo.xp_ReadErrorLog @p1 = 1
--3. OLEDB
if exists(select 1 from sys.tables where name = 'oledbProvider')
begin
drop table oledbProvider
end
create table oledbProvider
(
ProviderName nvarchar(50),
ProcessInfo nvarchar(100),
Text nvarchar(100)
)
insert into oledbProvider
execute master..xp_enum_oledb_providers
select *
from oledbProvider
--4.
if exists(select 1 from sys.tables where name = 'fixeddrivesFreeSpace')
begin
drop table fixeddrivesFreeSpace
end
create table fixeddrivesFreeSpace
(
drive nvarchar(10), -- , ':\'
freeSpace bigint -- MB
)
insert into fixeddrivesFreeSpace
execute master..xp_fixeddrives
select drive ' ',
freeSpace * 1.0 / 1024 ' (GB)'
from fixeddrivesFreeSpace
--5.
if exists(select 1 from sys.tables where name = 'availablemediaFreeSpace')
begin
drop table availablemediaFreeSpace
end
create table availablemediaFreeSpace
(
name nvarchar(10), -- , ':\'
lowFree bigint, -- 32
highFree int, -- 32
mediaType tinyint -- MB
)
insert into availablemediaFreeSpace
exec master.dbo.xp_availablemedia
/*=============================================
:
32 : lowfree (65536 * 65536)+ lowfree
32 :highfree * (65536 * 65536)
= 32 + 32
===============================================*/
select name ' ',
lowfree,
highfree,
case when sign(lowfree) = 1 -- 1
then lowfree + highfree * (1.0 * 65536 * 65536)
else lowfree + (1.0 * 65536 * 65536) + highfree * (1.0 * 65536 * 65536)
end / 1024 /1024 / 1024 ' (GB)',
case when mediaType = 1
then ' '
when mediaType = 2
then ' '
when mediaType = 8
then 'CD-ROM'
end ' '
from availablemediaFreeSpace
--6. windows
execute master..xp_enumgroups
--7.
/*========================================
1:
2:
3:
==========================================*/
-- c
execute master..xp_dirtree 'c:',1,1
-- c ,
execute master..xp_dirtree 'c:',1
-- c
execute master..xp_dirtree 'c:',0,1
--
EXEC master.dbo.xp_subdirs 'C:\'
--8.
if exists(select 1 from sys.tables where name = 'fileExists')
begin
drop table fileExists
end
create table fileExists
(
fileExists tinyint, --
IsDirectory tinyint, --
parentDirectoryExists tinyint --
)
insert into fileExists
execute master..xp_fileexist 'c:\c.txt'
select *
from fileExists
서비스 시작 여부 조회
-- SQL Server :MSSQLSERVER
select @@servicename
-- , CurrentServiceState :Running.
--
EXEC master.dbo.xp_servicecontrol
N'QUERYSTATE', --
N'MSSQLSERVER' -- SQL Server
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.