Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Using Execution Plan generates strange errors

Author  Topic 

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-27 : 07:09:14
After installing SP2 for SQL Serve 2005, I get strange errors when using either "Estimated Execution Plan" or "Actual Execution Plan".

Using "Estimated Execution Plan" generates this error
An error occurred while executing batch. Error message is: Error processing execution plan results. The error message is:
There is an error in XML document (1, 3998).
Unexpected end of file while parsing has occurred. Line 1, position 3998.


Using "Actual Execution Plan" generates this error
An error occurred while executing batch. Error message is: Error processing execution plan results. The error message is:
There is an error in XML document (1, 4001).
Unexpected end of file has occurred. The following elements are not closed: RelOp, ComputeScalar, RelOp, Update, RelOp, QueryPlan, StmtSimple, Statements, Batch, BatchSequence, ShowPlanXML. Line 1, position 4001.


All I do is testing this solution
declare	@t table (dt datetime)

insert @t
select '02-Jan-2007' union all
select '01-Feb-2007' union all
select '10-Feb-2007' union all
select '28-Feb-2007' union all
select '18-Mar-2007'

DECLARE @DaysRange INT,
@NumOfCalls INT

SELECT @DaysRange = 35,
@NumOfCalls = 4

SELECT t1.dt AS theDate
FROM @t AS t1
CROSS JOIN @t AS t2
WHERE t2.dt >= DATEADD(day, DATEDIFF(day, 0, t1.dt), 0)
AND t2.dt < DATEADD(day, DATEDIFF(day, 0, t1.dt), @DaysRange)
OR
t2.dt >= DATEADD(day, DATEDIFF(day, @DaysRange, t1.dt), 1)
AND t2.dt < DATEADD(day, DATEDIFF(day, 0, t1.dt), 1)
GROUP BY t1.dt
HAVING COUNT(*) >= @NumOfCalls
Has anyone else experienced this?


Peter Larsson
Helsingborg, Sweden

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2007-02-27 : 07:56:12
maybe direct to members PaulRandal or Mikewa...both work within Microsoft.
Go to Top of Page

paulrandal
Yak with Vast SQL Skills

899 Posts

Posted - 2007-02-27 : 10:05:29
I've forwarded this to the dev team...

Paul Randal
Principal Lead Program Manager, Microsoft SQL Server Core Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
http://blogs.msdn.com/sqlserverstorageengine/default.aspx
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-27 : 12:37:41
Thank you.

Now I get this result when using "Estimated Execution Plan" for same query as above
An error occurred while executing batch. Error message is: Error processing execution plan results. The error message is:
There is an error in XML document (1, 4001).
There is an unclosed literal string. Line 1, position 4001.


And this error when using "Actual Execution Plan"
An error occurred while executing batch. Error message is: Error processing execution plan results. The error message is:
There is an error in XML document (1, 4001).
Unexpected end of file while parsing Name has occurred. Line 1, position 4001.


I have not restarted SQL 2005 service since last error message, neither have I restarted SSMS. I have not closed the query window either. The only difference is that I emptied the query window and copied and pasted the query posted above.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-05 : 05:57:19
Today, when testing these solutions
-- Prepare sample data
set dateformat mdy

declare @process table (caseid int, processid int, procstartdate datetime, procenddate datetime)

insert @process
select 10, 1, '02-28-2005', '06-17-2005' union all
select 10, 2, '06-18-2005', '07-21-2005' union all
select 10, 3, '07-22-2005', '10-11-2005' union all
select 20, 1, '03-21-2005', '07-24-2005' union all
select 20, 2, '07-25-2005', '08-10-2005'

declare @letters table (caseid int, letterlogid int, entrydate datetime, amtofletters int)

insert @letters
select 10, 101, '04-15-2005', 1 union all
select 10, 102, '07-20-2005', 1 union all
select 10, 103, '09-16-2005', 1 union all
select 20, 201, '06-14-2005', 1 union all
select 20, 202, '06-19-2005', 1 union all
select 20, 203, '07-27-2005', 1 union all
select 20, 204, '07-29-2005', 1

declare @phonecalls table (caseid int, phonelogid int, entrydate datetime, amtofphonecalls int)

insert @phonecalls
select 10, 4101, '04-17-2005', 1 union all
select 10, 4102, '07-24-2005', 1 union all
select 10, 4103, '09-18-2005', 1 union all
select 10, 4104, '09-23-2005', 1 union all
select 10, 4105, '09-25-2005', 1 union all
select 20, 4106, '06-18-2005', 1 union all
select 20, 4107, '06-20-2005', 1 union all
select 20, 4108, '07-28-2005', 1 union all
select 20, 4109, '07-29-2005', 1

-- First try, INNER JOINs on LEFT JOINs GROUP BYs
SELECT x.CaseID,
x.ProcessID,
ISNULL(x.AmtOfLetters, 0) AS AmtOfLetters,
ISNULL(y.AmtOfPhoneCalls, 0) AS AmtOfPhoneCalls
FROM (
SELECT p.CaseID,
p.ProcessID,
SUM(l.AmtOfLetters) AS AmtOfLetters
FROM @Process AS p
LEFT JOIN @Letters AS l ON l.CaseID = p.CaseID AND l.EntryDate BETWEEN p.ProcStartDate AND p.ProcEndDate
GROUP BY p.CaseID,
p.ProcessID
) AS x
INNER JOIN (
SELECT p.CaseID,
p.ProcessID,
SUM(c.AmtOfPhoneCalls) AS AmtOfPhoneCalls
FROM @Process AS p
LEFT JOIN @PhoneCalls AS c ON c.CaseID = p.CaseID AND c.EntryDate BETWEEN p.ProcStartDate AND p.ProcEndDate
GROUP BY p.CaseID,
p.ProcessID
) AS y ON y.CaseID = x.CaseID AND y.ProcessID = x.ProcessID
ORDER BY x.CaseID,
x.ProcessID

-- Second try, INNER JOINs on UNIONs
SELECT CaseID,
ProcessID,
SUM(AmtOfLetters) AS AmtOfLetters,
SUM(AmfOfPhoneCalls) AS AmfOfPhoneCalls
FROM (
SELECT p.CaseID,
p.ProcessID,
l.AmtOfLetters,
0 AS AmfOfPhoneCalls
FROM @Process AS p
INNER JOIN @Letters AS l ON l.CaseID = p.CaseID AND l.EntryDate BETWEEN p.ProcStartDate AND p.ProcEndDate

UNION ALL

SELECT p.CaseID,
p.ProcessID,
0,
c.AmtOfPhoneCalls
FROM @Process AS p
INNER JOIN @PhoneCalls AS c ON c.CaseID = p.CaseID AND c.EntryDate BETWEEN p.ProcStartDate AND p.ProcEndDate

UNION ALL

SELECT p.CaseID,
p.ProcessID,
0,
0
FROM @Process AS p
) AS x
GROUP BY CaseID,
ProcessID
ORDER BY CaseID,
ProcessID

-- Third try, LEFT JOINs on UNIONs
SELECT CaseID,
ProcessID,
SUM(AmtOfLetters) AS AmtOfLetters,
SUM(AmfOfPhoneCalls) AS AmfOfPhoneCalls
FROM (
SELECT p.CaseID,
p.ProcessID,
ISNULL(l.AmtOfLetters, 0) AS AmtOfLetters,
0 AS AmfOfPhoneCalls
FROM @Process AS p
LEFT JOIN @Letters AS l ON l.CaseID = p.CaseID AND l.EntryDate BETWEEN p.ProcStartDate AND p.ProcEndDate

UNION ALL

SELECT p.CaseID,
p.ProcessID,
0,
ISNULL(c.AmtOfPhoneCalls, 0)
FROM @Process AS p
LEFT JOIN @PhoneCalls AS c ON c.CaseID = p.CaseID AND c.EntryDate BETWEEN p.ProcStartDate AND p.ProcEndDate
) AS x
GROUP BY CaseID,
ProcessID
ORDER BY CaseID,
ProcessID
I get these error messages:

Estimated Execution Plan
An error occurred while executing batch. Error message is: Error processing execution plan results. The error message is:
There is an error in XML document (1, 4001).
Unexpected end of file while parsing Name has occurred. Line 1, position 4001.


Actual Execution Plan
(5 row(s) affected)
An error occurred while executing batch. Error message is: Error processing execution plan results. The error message is:
There is an error in XML document (1, 4001).
Unexpected end of file while parsing Name has occurred. Line 1, position 4001.



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-06 : 13:14:52
There seems to be problem with your SQL Server installation, Peter.

I ran the same scripts on my machine and it's working fine with both estimated and actual execution plan.

I have SQL server 2005 Enterprise sp2 edition running on Windows 2003 SP1.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-06 : 13:45:16
Not all queries does this. The queries above works fine now and I haven't restarted my machine nor SQL service.
Happens only to one or two queries, every second or third day.

I am using SQL Server 2005 Developer Edition with SP2.
OS is Windows XP SP2.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-06 : 13:47:54
Installation of SQL SP2 went fine without any errors.
I only installed Database Enginge. Haven't installed SSIS, SSAS or RS.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-07 : 06:58:51
Well... That was not a good idea.

I uninstalled SQL Server from Control Panel and tried to install SQL Server from scratch.
The installation program tells me
"Service SQL Server (MSSQLServer) could not be installed. Verify that you have sufficient privileges to install system services".

I am logged on a local administrator, and now I have no SQL Server on my laptop!


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-07 : 07:13:38
Seems like something wrong with your registry. May be you can try re-installing the OS itself (Arghhhh...!!!).

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -