LogParser:SQL 表列“X”数据类型与 SELECT 子句项“cs-username”不兼容(类型字符串)
我正在尝试使用 LogParser 将 IIS 日志文件中的相关行插入到 SQL-Server 表中。
我按如下方式创建了表:
CREATE TABLE dbo.WebLog (Id INT IDENTITY, UserName VARCHAR(MAX),
URL VARCHAR(MAX), DateStampUTC DATETIME)
这就是我调用 LogParser 的方式:
LogParser "SELECT cs-username, cs-uri-stem, TO_TIMESTAMP(date,time)
INTO WebLog FROM ex*.log
WHERE cs-uri-stem IN ('urlsThatICareAbout.html') AND cs-username IS NOT NULL"
-server:<server>
-database:<database>
-username:<username>
-password:<password>
-transactionRowCount:-1
-ignoreIdCols:ON
-o:SQL
-driver:"SQL Server"
-i:IISW3C
我收到以下错误:
SQL table column "UserName" data type is not compatible with
SELECT clause item "cs-username" (type STRING)
有什么想法吗? STRING 和 VARCHAR(MAX) 类型不兼容吗?
I'm trying to use LogParser to insert relevant rows from IIS logfiles into a SQL-Server table.
I created my table as follows:
CREATE TABLE dbo.WebLog (Id INT IDENTITY, UserName VARCHAR(MAX),
URL VARCHAR(MAX), DateStampUTC DATETIME)
This is how I'm calling LogParser:
LogParser "SELECT cs-username, cs-uri-stem, TO_TIMESTAMP(date,time)
INTO WebLog FROM ex*.log
WHERE cs-uri-stem IN ('urlsThatICareAbout.html') AND cs-username IS NOT NULL"
-server:<server>
-database:<database>
-username:<username>
-password:<password>
-transactionRowCount:-1
-ignoreIdCols:ON
-o:SQL
-driver:"SQL Server"
-i:IISW3C
I'm getting the following error:
SQL table column "UserName" data type is not compatible with
SELECT clause item "cs-username" (type STRING)
Any ideas? Are types STRING and VARCHAR(MAX) incompatible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能希望将其减少到 NVARCHAR(1000) 甚至 255 或更少。 VARCHAR(max) 被一些较旧的库视为 TEXT/BLOB 类型。这也可能是 VARCHAR 和 NVARCHAR (对于国际字符)之间的区别
You might want to reduce that to something like NVARCHAR(1000) or even 255 or less. VARCHAR(max) is seen as a TEXT/BLOB type by some older libraries. It could also be the difference between VARCHAR and NVARCHAR (for international characters)
尝试使用本机 SQL Server 驱动程序,而不是默认使用 SQL Server ODBC 驱动程序——这一直对我有用。
Try using the native SQL Server driver and not defaulting to the SQL Server ODBC driver -- that has always worked for me.