2

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?

2 Answers 2

2

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)

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.