限制SQL Server只让指定的机器连接

honghu2100 2003-09-14 01:12:39
怎样才能限制我的SQL Server只能让指定的机器连接http://www.mypcera.com/softxue/7/sql/0034.htm
3. Write a constantly running/scheduled stored-procedure that checks the relevant column in sysprocesses (net_address), and then issues a KILL command for any processes that should not be running. Note that this only works for MAC addresses. This way allows people to connect and possibly make changes before they are spotted and killed.

写一个存储过程检查sysprocesses中的相应列(net_address)

请问这个存储过程怎样写?
...全文
94 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
CrazyFor 2003-09-15
  • 打赏
  • 举报
回复
限制某些IP访问你的服务器的某些端口,并不用命名管道连接.
liuyun2003 2003-09-15
  • 打赏
  • 举报
回复
TRY
declare @id int
DECLARE id_cursor CURSOR FOR
SELECT spid FROM master..sysprocesses where hostname not in(你允许的机器名,不要忘记加服务器的名字) ORDER BY spid
OPEN id_cursor

FETCH NEXT FROM id_cursor
INTO @id

WHILE @@FETCH_STATUS = 0
BEGIN
exec('kill '+cast(@id as varchar(10)))
FETCH NEXT FROM id_cursor
INTO @id
end
go
然后定时调用这段代码就可以了。
txlicenhe 2003-09-15
  • 打赏
  • 举报
回复
try:

declare @id int
select @id = spid from master..sysprocesses where hostname = '电脑名'
exec ('kill ' + @id)

leimin 2003-09-14
  • 打赏
  • 举报
回复
怎样才能限制我的SQL Server只能让指定的机器连接?
通过SQLSERVER不好限制,
最简单的方法是你通过USER/PASSWORD来限制。还有你可以通过FIRE WALL来限制,只可以通过指定的IP可以连接。你也可以自己写一个APPLICATION作为中间件来控制。
sdhdy 2003-09-14
  • 打赏
  • 举报
回复
别的机器如果不知道你的操作系统用户名和口令,或不知道你的SQL SERVER的SA的密码,就没法连接。

22,206

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧