SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having the following scenario. All day something I am testing has been working fine. but suddently I start receiving this error when I try to do the following line:

 query.RowLimit = 1;
                    SPListItemCollection itemsMeetings = listMeetingsRoot.GetItems(query);

                    if (itemsMeetings.Count == 1)

I am not going to show the full code because I think the error is related to sql server. but I dont know what to check 1. I checked tempdb it has 7mb of space. 2. I checked content database it has 60mb of data.

some errors I can see in the logs are:

Unable to execute query: Error 0x80131904
SqlError: 'Incorrect syntax near ')'.'    Source: '.Net SqlClient Data Provider' Number: 102 State: 1 Class: 15 Procedure: '' LineNumber: 1 Server:

...spaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.  Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.     at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)     at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)     at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)     at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()     at System.Data.SqlClient.Sql...

there are too many sql errors in the log, so I dont know what can I check

string startDateStr = startDate.ToString("s"); #endregion

            #region Get Next meeting                  

            SPQuery query = new SPQuery();
            query.Query = string.Concat(
                    "<FieldRef Name='" + Meetings.Common.Constants.FIELDS_TEXT_TITLE_NAME + "' />",
                    "<Value Type='Text'>" + type + "</Value>",
                    "<FieldRef Name='" + Meetings.Common.Constants.FIELDS_EVENTDATE_NAME + "' />",
                    "<Value Type='DateTime' IncludeTimeValue='TRUE'>" + startDateStr + "</Value>",
            query.RowLimit = 1;
            SPListItemCollection itemsMeetings = listMeetingsRoot.GetItems(query);

            #region Get url of next meeting site
            if (itemsMeetings.Count == 1)

this is the generated query

<Where><And><BeginsWith><FieldRef Name='Title' /><Value Type='Text'>BD</Value></BeginsWith><Ge><FieldRef Name='EventDate' /><Value Type='DateTime' IncludeTimeValue='TRUE'>2012-08-15T00:00:00</Value></Ge></And></Where>
share|improve this question
The SQL query is malformed. What's your CAML look like? – RJ Cuthbertson Aug 13 '12 at 18:21
please see the update. – Esteban V Aug 13 '12 at 18:34
up vote 4 down vote accepted

Two things here.

First, the CAML schema uses <Geq> rather than <Ge>. See Query Schema.

Second, SharePoint dates comply to ISO 8601 standards. This requires you to include Zulu in the string (as in yyyy-MM-ddTHH:mm:ssZ). See SharePoint 2010: Working With Dates in CAML.

share|improve this answer
shame on me, I meant gt.. – Esteban V Aug 13 '12 at 18:57
Sometimes you just need a fresh pair of eyes. – RJ Cuthbertson Aug 13 '12 at 19:11
What would be the chances. Exactly same issue with the Ge vs Geq. My COBOL days of old have come back to haunt me. – Swanny Sep 2 '13 at 20:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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