September 25, 2012 at 8:24 pm
I am getting error in below code:
SET NOCOUNT ON
CREATE TABLE #EVENTS (LOGDATE DATETIME, PROCESSINFO VARCHAR(50), VCHMESSAGE VARCHAR(800), SOURCE VARCHAR(20), CROW INT)
-- CHECK FOR SQL INSTALLATION WHETHER IF 2000 OR 2005 --
-- IN CASE OF 2000, XP_READERRORLOG GIVES ONLY SQL SERVER LOGS AND OUTPUTS ONLY 2 COLUMNS --
-- IN CASE OF 2005, XP_READERRORLOG GIVES BOTH SQL SERVER AND AGENT LOGS --
IF (SELECT LEFT(CAST(SERVERPROPERTY('PRODUCTVERSION') AS VARCHAR),1)) = 8
BEGIN
INSERT INTO #EVENTS (VCHMESSAGE, CROW) EXEC XP_READERRORLOG
UPDATE #EVENTS SET LOGDATE = SUBSTRING(VCHMESSAGE,1,19), PROCESSINFO = 'SERVER', SOURCE = 'SQL SERVER'
WHERE SUBSTRING(VCHMESSAGE,1,3)='200' and substring(VCHMESSAGE,5,5)='-'
END
ELSE
BEGIN
INSERT INTO #EVENTS (LOGDATE, PROCESSINFO, VCHMESSAGE) EXEC XP_READERRORLOG 0,1 -- CURRENT LOGS, SQL SERVER
UPDATE #EVENTS SET SOURCE = 'SQL SERVER'
INSERT INTO #EVENTS (LOGDATE, PROCESSINFO, VCHMESSAGE) EXEC XP_READERRORLOG 0,2 -- CURRENT LOGS, SQL SERVER AGENT
UPDATE #EVENTS SET SOURCE = 'SQL SERVER AGENT' WHERE SOURCE IS NULL
END
The error which i am getting is :
Msg 8152, Level 16, State 2, Procedure xp_readerrorlog, Line 1
String or binary data would be truncated.
Please if some can help......
September 26, 2012 at 1:10 am
I'd say you need to expand the size of one or more of your varchar columns. Not sure which but that's where I'd start. My google-fu isn't very strong today.
September 26, 2012 at 1:28 am
It got resolved by changing VCHMESSAGE VARCHAR(800)
to VCHMESSAGE VARCHAR(max)
September 26, 2012 at 7:57 am
That is one of the most irritating things about sql server. There is a connect issue somewhere to change the message of that error to include the column name. DUH!!! Of course the engine knows which column threw the error, not returning it in the error message is just sad.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 27, 2012 at 7:30 am
Hi,
Before inserting the data, find out what the MAX(LEN(Col)) is for each column. Compare the results to your variable declarations and destination table design.
Btw, varchar(max) isn't recognized in SQL 2000. Better find out what it needs to be at the moment and add a little buffer. But if must be as big as possible use varchar(8000) instead.
Goodluck.
September 27, 2012 at 7:35 am
D.Post (9/27/2012)
Hi,Before inserting the data, find out what the MAX(LEN(Col)) is for each column. Compare the results to your variable declarations and destination table design.
Btw, varchar(max) isn't recognized in SQL 2000. Better find out what it needs to be at the moment and add a little buffer. But if must be as big as possible use varchar(8000) instead.
Goodluck.
varchar(4000) is the largest size in sql 2000. 😀
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 27, 2012 at 8:58 am
September 27, 2012 at 10:00 am
I disagree, varchar can hold up to 8000 characters in 2000 (nvarchar will only hold up to 4000, though).
http://msdn.microsoft.com/en-us/library/aa258242(SQL.80).aspx
Another option is to use text columns
September 27, 2012 at 11:54 am
Luis Cazares (9/27/2012)
I disagree, varchar can hold up to 8000 characters in 2000 (nvarchar will only hold up to 4000, though).http://msdn.microsoft.com/en-us/library/aa258242(SQL.80).aspx
Another option is to use text columns
Doh!!! You are right Luis, thanks for the correction to my incorrect correction. 😉
I too haven't 2000 in a long long time.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 27, 2012 at 12:10 pm
Sean Lange (9/27/2012)
Luis Cazares (9/27/2012)
I disagree, varchar can hold up to 8000 characters in 2000 (nvarchar will only hold up to 4000, though).http://msdn.microsoft.com/en-us/library/aa258242(SQL.80).aspx
Another option is to use text columns
Doh!!! You are right Luis, thanks for the correction to my incorrect correction. 😉
I too haven't 2000 in a long long time.
I remember the number because of the 8K Splitter.;-)
I just had to find the reference to confirm it.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply