2009年1月22日星期四

SQL SERVER 默认数据库实例的作用

master 数据库
master 数据库记录 SQL Server 系统的所有系统级别信息。它记录所有的登录帐户和系统配置设置,所有其它的数据库,其中包括数据库文件的位置。master 数据库记录 SQL Server 的初始化信息,它始终有一个可用的最新 master 数据库备份。

tempdb 数据库
tempdb 数据库保存所有的临时表和临时存储过程。它还满足任何其它的临时存储要求,例如存储 SQL Server 生成的工作表。tempdb 数据库是全局资源,所有连接到系统的用户的临时表和存储过程都存储在该数据库中。tempdb 数据库在 SQL Server 每次启动时都重新创建,因此该数据库在系统启动时总是干净的。临时表和存储过程在连接断开时自动除去,而且当系统关闭后将没有任何连接处于活动状态,因此 tempdb 数据库中没有任何内容会从 SQL Server 的一个会话保存到另一个会话。

默认情况下,在 SQL Server 在运行时 tempdb 数据库会根据需要自动增长。不过,与其它数据库不同,每次启动数据库引擎时,它会重置为其初始大小。如果为 tempdb 数据库定义的大小较小,则每次重新启动 SQL Server时,将tempdb 数据库的大小自动增加到支持工作负荷所需的大小这一工作可能会成为系统处理负荷的一部分。为避免这种开销,可以使用 ALTER DATABASE 增加 tempdb 数据库的大小。

model 数据库
model 数据库用作在系统上创建的所有数据库的模板。当发出 CREATE DATABASE 语句时,新数据库的第一部分通过复制 model 数据库中的内容创建,剩余部分由空页填充。由于 SQL Server 每次启动时都要创建 tempdb 数据库,model 数据库必须一直存在于 SQL Server 系统中。

msdb 数据库
msdb 数据库供 SQL Server 代理程序调度警报和作业以及记录操作员时使用。

Northwind 示例数据库
Northwind Traders 示例数据库包含一个名为 Northwind Traders 的虚构公司的销售数据,该公司从事世界各地的特产食品进出口贸易

pubs 示例数据库
pubs 示例数据库以一个图书出版公司为模型,用于演示 SQL Server 数据库中可用的许多选项。该数据库及其中的表经常在文档内容所介绍的示例中使用。

2009年1月16日星期五

vbs修改注册表 添加IE浏览器信任站点

Windows xp系统可以通过以下脚本来添加域名地址到IE浏览器信任站点
On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001
strUrl_base = "google.com"
strUrl = strUrl_base & "\www"
strComputer = "."
Set objReg = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}\\" & strComputer & _
"\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
& "ZoneMap\Domains\" & strUrl_base
objReg.CreateKey HKEY_CURRENT_USER,strKeyPath
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
& "ZoneMap\Domains\" & strUrl
objReg.CreateKey HKEY_CURRENT_USER,strKeyPath
strValueName = "http"
dwValue = 2
objReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
Wscript.Echo "Added http://www.google.com to Trusted sites Zone successfully."
如果是Windows 2003操作系统则需要把注册表路径Domains修改为EscDomains即可。

'**************************************************
Windows xp系统可以通过以下脚本来添加IP地址到IE浏览器信任站点
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = CreateObject("WScript.Shell")
on Error resume next
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range111\",""
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range111\http","2","REG_DWORD"
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range111\:Range","192.168.2.11"
Wscript.Echo "Added http://192.168.2.11 to Trusted sites Zone successfully."
如果是Windows 2003操作系统则需要把注册表路径Ranges修改为EscRanges即可。

2009年1月5日星期一

使用vbs脚本通过SMTP服务批量发送邮件

'从数据库用户表中取出邮件信息循环发送
set cndb=CreateObject("ADODB.Connection")
cndb.open "Provider=SQLOLEDB.1;Password=[密码];Persist Security Info=True;User ID=[数据库用户名];Initial Catalog=test;Data Source=[数据库]"
on error resume next
sql="select * from [数据表]"
set rs=createobject("adodb.recordset")
rs.open sql,cndb,1,1
servername=""
do until rs.eof
Wscript.Echo trim(rs.Fields("mailbox"))
sendmail "发送人邮箱",trim(rs.Fields("mailbox")),"关于停止使用旧邮件系统的通知","",txt
rs.movenext
loop
msgbox "ok"
function sendmail(mailfrom,mailto,mailsubject,mailcc,mailtext)
ON ERROR RESUME NEXT
sendmail=0
Dim msg
Dim iConf
Dim Flds
set msg =CreateObject ("cdo.message")
set iconf =CreateObject ("cdo.configuration")
set Flds = iConf.Fields
ExpiredTime = 172800
' Set the configuration for Network Send
with flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'可用的SMTP服务器[测试开通] telnet inner.chinaXXX.com 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "inner.chinaXXX.com"
.Item("cdoSMTPServerPort") = 25
.Item("cdoSMTPConnectionTimeout") = 30
.Item("cdoSMTPAccountName") = mailfrom
.Item("cdoSendUserReplyEmailAddress") = mailfrom
.Item("cdoSendEmailAddress") = mailfrom
.Update
end with
Set msg.Configuration = iConf
With msg
.From = mailfrom
.To = mailto
.CC = mailcc
.Subject = mailsubject
'.TextBody = mailtext
.CreateMHTMLBody "http://localhost/SendMail.htm", cdoSuppressNone
'添加附件
.AddAttachment "d:\zn\手册.doc"
'.BodyFormat = 0
.Send
End With
if err.number<>0 then
Wscript.Echo "False--" & trim(rs.Fields("mailbox"))
err.number=0
end if
set iConf = nothing
Set msg = Nothing
set flds = nothing
end function