来自 澳门威尼斯人注册网站 2020-02-15 21:14 的文章
当前位置: 澳门威尼斯人平台 > 澳门威尼斯人注册网站 > 正文

知方可补不足~数据库名称和数据库别名不同了怎么办

回到目录

回到目录

LogParser是微软开发的一个日志分析工具,它是命令行格式的,我们通过这个工具,可以对日志文件进行操作,对于一个几百兆的log文件,使用记事本打开是件很残酷的事,所以,很多情况下,我们都会将大日志文件的内容插入到数据库中,这样有利于我们更好的去分析系统的日志。

当你的数据库安装成功后,你修改了计算机名称,这时,你的sqlserver名称与别名可能就不相同了,当这两个名称不相同时,你再使用sql的发布与订阅功能时,将会被提示出错,“请使用服务名称,不能使用别名和IP地址”,下面是具体解决方法

脚本中心给它的定义

use master
go
select @@servername;
select serverproperty('servername')

Log Parser 2.2 是一个功能强大的通用工具,它可对基于文本的数据(如日志文件、

得到的结果表明,这两个名称确实不一样

建立日志数据库和数据表

USE [Log_IIS]GO/****** Object: Table [dbo].[Online_tj]  Script Date: 10/28/2011 17:08:28 ******/IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Online_tj]') AND type in (N'U'))DROP TABLE [dbo].[Online_tj]GOUSE [Log_IIS]GO/****** Object: Table [dbo].[Online_tj]  Script Date: 10/28/2011 17:08:28 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[Online_tj](  [ID] [int] IDENTITY(1,1) NOT NULL,  [logtime] [datetime] NULL,
  [s_ip] [varchar](255) NULL,  [cs_method] [varchar](255) NULL,  [cs_uri_stem] [varchar](255) NULL,  [cs_uri_query] [varchar](1024) NULL,  [s_port] [int] NULL,  [cs_username] [varchar](255) NULL,  [c_ip] [varchar](255) NULL,  [cs_User_Agent] [varchar](255) NULL,  [sc_status] [int] NULL,  [sc_substatus] [int] NULL,  [sc_win32_status] [int] NULL,  [time_taken] [int] NULL, CONSTRAINT [PK__Online_tj__164452B1] PRIMARY KEY CLUSTERED (  [ID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]GOSET ANSI_PADDING OFFGOUSE [Log_IIS]/****** Object: Index [IX_Online_tj_CI_LCCC]  Script Date: 10/28/2011 17:08:29 ******/CREATE NONCLUSTERED INDEX [IX_Online_tj_CI_LCCC] ON [dbo].[Online_tj] (  [cs_uri_stem] ASC,  [ID] ASC)INCLUDE ( [logtime],[c_ip],[cs_uri_query],[cs_User_Agent]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]GOUSE [Log_IIS]/****** Object: Index [ix_Online_tj_logtime]  Script Date: 10/28/2011 17:08:29 ******/CREATE NONCLUSTERED INDEX [ix_Online_tj_logtime] ON [dbo].[Online_tj] (  [logtime] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]GO

图片 1

添加SQL脚本

/*  logparser file:tj_insert.sql?start=starttime+end=endtime+log=logfilename  input parameter:      start  -  starttime  example:1:00:00 or 18:00:00      end  -  endtime    example:1:09:59  or 18:59:59      log  -  logfilename  example:ex10111601 or ex10111618      */Select TO_TIMESTAMP(date,time), TO_TIMESTAMP(date,time), s-ip, cs-method, cs-uri-stem, cs-uri-query, s-port, cs-username, c-ip,  cs(User-Agent), sc-status, sc-substatus, sc-win32-status, time-takenINTOLog_IIS.dbo.Online_tjFROME:tjIISLogW3SVC10%log%.logWHERE TO_LOCALTIME(Time) BETWEEN TO_TIMESTAMP('%start%','h:mm:ss') AND TO_TIMESTAMP('%end%','h:mm:ss')

然后我们把老的名称删除,换成现在的别名

本文由澳门威尼斯人平台发布于澳门威尼斯人注册网站,转载请注明出处:知方可补不足~数据库名称和数据库别名不同了怎么办

关键词: