仓酷云

标题: MSSQL网站制作之怎样经由过程T-SQL取得以后毗连的客户真个I... [打印本页]

作者: 愤怒的大鸟    时间: 2015-1-16 22:29
标题: MSSQL网站制作之怎样经由过程T-SQL取得以后毗连的客户真个I...
修复过程包含最多4个阶段,在下面描述。在你开始前,你应该cd到数据库目录和检查表文件的权限,确保他们可被运行mysqld的Unix用户读取(和你,因为你需要存取你正在检查的文件)。如果它拒绝你修改文件,他们也必须是可被你写入的。客户端
/*****************************************************************************************************************

上面的SP是前往一切的客户真个IP和HOSTNAME,目标是能够经由过程JOB前往某一工夫点的CLIENT的毗连情形.

我事先写这个剧本的目标是常常有一些没有受权的客户机,经由过程SQLSERVER的CLIENT就毗连到SQLSERVER,以是我能够界说一个JOB每隔30分钟运转一次这个存储历程,而且将内容写的一个LOG文件,如许能够也许纪录有哪些CLIENT在毗连SQLSERVER,固然人人能够能够修正这个剧本,使之前往更多的信息,好比CPU,MEMORY,LOCK....

Author:黄山光亮顶

mail:leimin@jxfw.com

version:1.0.0

date:2004-1-30

(如需转载,请说明出处!)

*********************************************************************************************************/

Createprocusp_getClient_infor
as
setnocounton

Declare@rcint
Declare@RowCountint

Select@rc=0
Select@RowCount=0

begin
--//createtemptable,savesp_whoinformation
createtable#tspid(
spidintnull,
ecidintnull,
statusnchar(60)null,
loginnamenchar(256)null,
hostnamenchar(256)null,
blkbitnull,
dbnamenchar(256)null,
cmdnchar(32)
)

--//createtemptablesaveallSQLclientIPandhostnameandlogintime
Createtable#userip(
[id]intidentity(1,1),
txtvarchar(1000),
)

--//Createresulttabletoreturnrecordset
Createtable#result(
[id]intidentity(1,1),
ClientIPvarchar(1000),
hostnamenchar(256),
login_timedatetimedefault(getdate())

)
--//gethostnamebyexecsp_who,insert#tspidfromsp_who,
insertinto#tspid(spid,ecid,status,loginname,hostname,blk,dbname,cmd)execsp_who

declare@cmdStrvarchar(100),
@hostNamenchar(256),
@useripvarchar(20),
@sendstrvarchar(100)


--//declareacursorfromtable#tspid
declaretspidcursor
forselectdistincthostnamefrom#tspidwith(nolock)wherespid>50
forreadonly

opentspid
fetchnextfromtspidinto@hostname
While@@FETCH_STATUS=0
begin
select@cmdStr=ping+rtrim(@hostName)

insertinto#userip(txt)execmaster..xp_cmdshell@cmdStr

select@rowcount=count(id)from#userIP


if@RowCount=2--//noIPfeedbackpackage
begin
insertinto#Result(ClientIP,hostname)values(CannotgetfeedbackpackagefromPing!,@hostname)
end
if@RowCount>2
begin
select@userip=substring(txt,charindex([,txt)+1,charindex(],txt)-charindex([,txt)-1)
from#userIP
wheretxtlikePinging%

insertinto#Result(ClientIP,hostname)values(@userIP,@hostname)
end
select@rc=@@error
if@rc=0
truncatetable#userip--//clear#userIPtable

fetchnextfromtspidinto@hostname
end

closetspid
deallocatetspid

select*from#resultwith(nolock)

droptable#tspid
droptable#userip
droptable#result
end
go
execusp_getClient_infor
这章描述如何检查和处理在MySQL数据库中的数据损坏。如果你的表损坏很多,你应该尝试找出其原因!见G.1调试一个MySQL服务器。
作者: 乐观    时间: 2015-1-18 18:04
对于数据库来说,查询是数据库的灵魂,那么SQL查询效率究竟效率如何呢?下文将带对SQL查询的相关问题进行讨论,供您参考。
作者: 蒙在股里    时间: 2015-1-22 19:56
然后最好有实践机会,能够把实践到的和实践结合起来,其实理论思考是个非常困扰和痛苦的事情
作者: 小魔女    时间: 2015-1-31 11:21
财务软件要用SQL也只是后台的数据库而已,软件都是成品的,当然多学东西肯定是有好处的..
作者: 若天明    时间: 2015-2-6 19:10
两个月啃那本sqlserver2005技术内部-存储引擎,花了几个月啃四本书
作者: 不帅    时间: 2015-2-18 08:58
只能告诉你,学好数据库语言和原理,多见识几种数据库软件,比一棵树上吊死要好。
作者: 只想知道    时间: 2015-3-6 03:29
对递归类的树遍历很有帮助。个人感觉这个真是太棒了!阅读清晰,非常有时代感。
作者: 分手快乐    时间: 2015-3-12 19:31
发几份SQL课件,以飨阅者
作者: 小女巫    时间: 2015-3-20 02:17
然后最好有实践机会,能够把实践到的和实践结合起来,其实理论思考是个非常困扰和痛苦的事情




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2