LogParser: SQL table column "X" data type is not compatible with SELECT clause item "cs-username" (type STRING)
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 cl开发者_如何学运维ause item "cs-username" (type STRING)
Any ideas? Are types STRING and VARCHAR(MAX) incompatible?
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)
Try using the native SQL Server driver and not defaulting to the SQL Server ODBC driver -- that has always worked for me.
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 Native Client 10.0"
-i:IISW3C
精彩评论