View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
05063Bug reportsImport/Exportpublic2011-07-22 16:23
Reporteruser13042Assigned Toc_schmitz  
PrioritynormalSeveritypartial_block 
Status closedResolutionfixed 
Product Version1.90+ 
Fixed in Version1.91+ 
Summary05063: Import fails on MSSQL 2008
Description

Import failed with message:
Operand type clash: datetime2 is incompatible with int

Steps To Reproduce

Repeatable with any survey being exported from a linux system and into a Windows system with MSSQL 2008. Have tested it with both our systems and it appears to be repeatable.

Additional Information

Tracked issue down to importsurvey.php under Import surveys table

The startdate was set to 0 in the query. I changed this to set it to null instead and the import worked fine.

This, I believe, is due to a change in how MSSQL 2008 handles dates though I could be wrong.

TagsNo tags attached.
Attached Files
Bug heat6
Complete LimeSurvey version number (& build)9642
I will donate to the project if issue is resolvedNo
BrowserFirefox 3.6 / Firefox 4
Database type & versionMysql 5.0.26 on export and MSSQL 2008 on import
Server OS (if known)Export:SLES10SP3 (2.6.16.60-0.77.1-smp), Import: Windows Server 2003 R2 Standard x64 Edition Service Pack 2
Webserver software & version (if known)Export: Apache 2.2, Import:IIS6
PHP VersionExport:5.3.6 , Import:5.3.6

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2011-03-29 19:56

administrator   ~14606

Which mssql driver are you using in config.php?

user13042

2011-03-30 10:23

  ~14618

The odbc_mssql driver.

c_schmitz

c_schmitz

2011-04-04 12:57

administrator   ~14650

Sorry, can't reproduce. When I export the startdate is empty here. I guess for some reason there is a 0 in your mysql DB in the startdate field. Can you check?

c_schmitz

c_schmitz

2011-04-11 13:43

administrator   ~14776

lisnalinchy, please give feedback or we will have to close this issue.

user13042

2011-04-11 13:50

  ~14777

My apologies, I have just returned from annual leave.

Just had a look in the lime_surveys table - startdate is set to NULL across the board bar one which has an actual start date of 2010-11-23 00:00:00

c_schmitz

c_schmitz

2011-04-11 14:11

administrator   ~14781

lisnalinchy, I don't understand - either the startdate is set to NULL or it is set to 2010-11-23 00:00:00 ?

user13042

2011-04-11 14:54

  ~14782

There are 15 surveys - all the surveys in the table with the exception of one have a start date of NULL. There is only one survey in the table with an actual start date.

c_schmitz

c_schmitz

2011-04-11 17:33

administrator   ~14783

So when you export such a survey with a startdate of NULL in the DB then the export file contains a 0 instead? Can you attach such a file? What driver are you using, mysql or mysqli on server?

user13042

2011-04-12 10:36

  ~14789

I can replicate this if, on the linux/mysql box I set a start date for the survey and then try to import it into the windows/MSSQL box.

The error on import into the Windows/MSSQL box is:

Error: Failed to insert data
INSERT INTO lime_surveys ( SID, OWNER_ID, ADMIN, ACTIVE, EXPIRES, ADMINEMAIL, PRIVATE, FAXTO, FORMAT, TEMPLATE, LANGUAGE, ADDITIONAL_LANGUAGES, DATESTAMP, USECOOKIE, NOTIFICATION, ALLOWREGISTER, ALLOWSAVE, AUTONUMBER_START, AUTOREDIRECT, ALLOWPREV, PRINTANSWERS, IPADDR, REFURL, DATECREATED, LISTPUBLIC, HTMLEMAIL, TOKENANSWERSPERSISTENCE, USECAPTCHA, BOUNCE_EMAIL, STARTDATE, PUBLICSTATISTICS, PUBLICGRAPHS, ASSESSMENTS, USETOKENS, ATTRIBUTEDESCRIPTIONS, EMAILRESPONSETO, TOKENLENGTH ) VALUES ( 33397, 1, 'Michael Ross', 'N', '2011-04-26', 'michael.ross@nhsleeds.nhs.uk', 'Y', '', 'G', 'default', 'en', '', 'N', 'N', '0', 'N', 'Y', 0, 'N', 'Y', 'N', 'N', 'N', '2011-04-12', 'N', 'Y', 'N', 'D', 'michael.ross@nhsleeds.nhs.uk', 2011, 'N', 'N', 'N', 'N', '', '', 15 )
[Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: int is incompatible with datetime2

I have uploaded the LSS file I used for import as requested.

I am using the mysql driver on the Linux server.

If I do not specify a start date, the import works fine. If I do specify a start date, I get the error.

Looking at the importsurvey.php script, it actually sets the start date to 0 rather than NULL which (as you can see from the error) does not work. This is actually a documented issue with MSSQL 2008 and above.

user13042

2011-04-12 10:41

  ~14791

Correct to the above feedback:

It does not matter if I specify a start date or not, I still get this error. I had forgotten to remove my fix before testing. Returning the original importsurvey.php file results in this error being generated every time.

c_schmitz

c_schmitz

2011-04-12 12:12

administrator   ~14792

I can import the attached file just fine on my MSSQL 2008 server with LimeSurvey 1.90 (9642)
Are you sure the LimeSurvey version on the destination server is up to date?

user13042

2011-04-12 12:43

  ~14793

Version is reporting as: Version 1.90+ Build 9642 on both servers.

I will try creating a new instance of Limesurvey on our Windows/MSSQL box and test the import.

c_schmitz

c_schmitz

2011-04-12 13:29

administrator   ~14794

Please do. Maybe the installation on the server was updated in the past and not allf iles were properly replaced with new versions.

medicnick

medicnick

2011-04-13 07:06

reporter   ~14807

lisnalinchy, I too have MSSQL2008 (R2) and have discovered that more than just this one table have NO default values set. Can you confirm if any default values are set in any tables and if any identity parameters have been set?

In MSMS you can open columns, right click and choose modify. Then scroll through the properties. The default value should be set there and if an identity is required it will be set to Yes and 1 and 1. Thanks!

c_schmitz

c_schmitz

2011-04-13 16:46

administrator   ~14812

medicnick, this is not a problem of neither a missing default value nor missing identity. Please don't interfere.

user13042

2011-04-15 08:50

  ~14819

I must apologies that I have not yet managed to get round to this. I am currently snowed under with other work. I will be doing this on Monday.

user13042

2011-04-19 13:33

  ~14844

I have built a new Limesurvey/Windows/MSSQL box and the issue appears to have gone. It looks like the issue was due to some files that had not been updated during that last update. For reference, I had used the web based in-line upgrade. I will probably do this by hand in future.

Many thanks for all your help and time.

user13042

2011-07-19 16:58

  ~15799

There is still an issue here. I have just clean installed the latest version on both our linux and windows boxes. Testing an import, the import fails with the same error. Both version are identical except one is running on linux with MySQL and the other is running on Windows Server 2008R2 (iis 7.5) with MSSQL 2008R2.

A simple fix is to insert:
$insertdata['startdate']='null';
into import_functions.php at or around line 1170.

As far as I understand, startdate is supposed to be set to null anyway for an import. No harm in reinforcing it and it resolves the issue.

c_schmitz

c_schmitz

2011-07-19 17:08

administrator   ~15801

I am sorry but by now your version is old. Please update to 1.91+ and see if the issue is resolved there. Feel free to re-open this if you can still reproduce it.

user13042

2011-07-19 17:18

  ~15804

Apologies, perhaps I was not very clear. In my comment I referred to the latest version - I should have been more specific and said '1.91+' - the latest available stable release as of today - is the one I am using.

There does not appear to be any way to change the 'Product version' in the details table above i'm afraid. Do you want me to re-open this as a new report?

c_schmitz

c_schmitz

2011-07-21 18:18

administrator   ~15820

Even though I cannot reproduce the issue at all I put in a similar fix now for the .lss import.

c_schmitz

c_schmitz

2011-07-22 16:23

administrator   ~15831

New 1.91+ version released

Issue History

Date Modified Username Field Change
2011-03-28 12:19 user13042 New Issue
2011-03-29 19:56 c_schmitz Note Added: 14606
2011-03-29 19:56 c_schmitz Assigned To => c_schmitz
2011-03-29 19:56 c_schmitz Status new => feedback
2011-03-30 10:23 user13042 Note Added: 14618
2011-03-30 10:23 user13042 Status feedback => assigned
2011-04-04 12:57 c_schmitz Note Added: 14650
2011-04-04 12:57 c_schmitz Status assigned => feedback
2011-04-11 13:43 c_schmitz Note Added: 14776
2011-04-11 13:50 user13042 Note Added: 14777
2011-04-11 13:50 user13042 Status feedback => assigned
2011-04-11 14:11 c_schmitz Note Added: 14781
2011-04-11 14:13 c_schmitz Status assigned => feedback
2011-04-11 14:54 user13042 Note Added: 14782
2011-04-11 14:54 user13042 Status feedback => assigned
2011-04-11 17:33 c_schmitz Note Added: 14783
2011-04-11 18:51 c_schmitz Status assigned => feedback
2011-04-12 10:36 user13042 Note Added: 14789
2011-04-12 10:36 user13042 Status feedback => assigned
2011-04-12 10:36 user13042 File Added: limesurvey_survey_33397(1).lss
2011-04-12 10:41 user13042 Note Added: 14791
2011-04-12 12:12 c_schmitz Note Added: 14792
2011-04-12 12:25 c_schmitz Status assigned => feedback
2011-04-12 12:43 user13042 Note Added: 14793
2011-04-12 12:43 user13042 Status feedback => assigned
2011-04-12 13:29 c_schmitz Note Added: 14794
2011-04-12 15:24 c_schmitz Relationship added related to 04965
2011-04-12 15:25 c_schmitz Relationship deleted related to 04965
2011-04-13 07:06 medicnick Note Added: 14807
2011-04-13 16:46 c_schmitz Note Added: 14812
2011-04-15 08:50 user13042 Note Added: 14819
2011-04-19 13:33 user13042 Note Added: 14844
2011-04-19 16:02 c_schmitz Status assigned => closed
2011-04-19 16:02 c_schmitz Resolution open => unable to reproduce
2011-07-19 16:58 user13042 Note Added: 15799
2011-07-19 16:58 user13042 Status closed => feedback
2011-07-19 16:58 user13042 Resolution unable to reproduce => reopened
2011-07-19 17:08 c_schmitz Note Added: 15801
2011-07-19 17:08 c_schmitz Status feedback => closed
2011-07-19 17:08 c_schmitz Resolution reopened => unable to reproduce
2011-07-19 17:18 user13042 Note Added: 15804
2011-07-19 17:18 user13042 Status closed => feedback
2011-07-19 17:18 user13042 Resolution unable to reproduce => reopened
2011-07-21 18:18 c_schmitz Note Added: 15820
2011-07-21 18:18 c_schmitz Status feedback => resolved
2011-07-21 18:18 c_schmitz Fixed in Version => 1.91+
2011-07-21 18:18 c_schmitz Resolution reopened => fixed
2011-07-22 16:23 c_schmitz Note Added: 15831
2011-07-22 16:23 c_schmitz Status resolved => closed