Microsoft Knowledge Base Email Alertz

(330741) - When you use the Push method in Microsoft SQL Server 2000 Windows CE Edition 2.0 (SQL Server CE) Remote Data Access (RDA) to transfer data from a SQL Server CE database table to a remote SQL Server database table, the data transfer may fail. This...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 330741 - Last Review: December 7, 2006 - Revision: 3.5

BUG: A transfer of data from a SQL Server CE or SQL Server 2005 Compact Edition database to a remote SQL Server database fails when you use the Push method in SQL Server CE Remote Data Access

This article was previously published under Q330741
BUG #: 5612 (SQL Server CE)

On This Page

SYMPTOMS

When you use the Push method in Microsoft SQL Server 2000 Windows CE Edition 2.0 (SQL Server CE) or SQL Server 2005 Compact Edition Remote Data Access (RDA) to transfer data from a SQL Server CE or SQL Server 2005 Compact Edition database table to a remote SQL Server database table, the data transfer may fail. This problem may occur if all the following conditions are true:
  • The destination table in the remote SQL Server database contains one or more columns that are defined as NOT NULL.
  • The SQL Server CE database table contains rows with an empty string or with space values for columns that correspond to the NOT NULL columns on the destination table.

If a row with an empty string or with space values is inserted in the destination table, you may notice NULL values in the nullable columns.

You may not notice this behavior when you use replication to transfer data between a SQL Server CE or SQL Server 2005 Compact Edition database and a SQL Server database.

Note This problem does not occur in Microsoft SQL Server 2000 Windows CE version 1.1.

CAUSE

The Push method in SQL Server CE RDA or in SQL Server 2005 Compact Edition RDA treats empty string or space values as NULL values.

WORKAROUND

To work around the problem, change the column definition of the columns that are defined as NOT NULL on the destination table in the remote SQL Server database to NULL.

Note Before you re-define a column of the destination table as NULL, make sure that this change does not affect the integrity or the consistency of your database.

MORE INFORMATION

Steps to reproduce the behavior

  1. Run the following Transact-SQL statement on the remote SQL Server database:
    CREATE TABLE TestNull (c1 INT PRIMARY KEY, c2 NVARCHAR(30)  NOT NULL)
  2. Using an application that uses SQL Server CE RDA, pull the TestNull table into the SQL Server CE database on your handheld device.
  3. Run the following Transact-SQL statements on the SQL Server CE database to insert test rows:
    INSERT INTO TestNull (c1, c2) VALUES (1, ' ') 
    INSERT INTO TestNull (c1, c2) VALUES (2, '  ')
    INSERT INTO TestNull (c1, c2) VALUES (3, '')
    INSERT INTO TestNull (c1, c2) VALUES (4, NULL)
  4. Using SQL Server CE RDA, push the TestNull table back to the remote SQL Server database.

    Note You may notice that the insert of all the rows fails. The insert fails because the c2 column in the TestNull table on the remote SQL Server database does not accept NULL values.

Workaround example


Re-create the TestNull table with the c2 column as nullable, and then perform the data transfer by using SQL Server RDA. To do so, follow these steps:
  1. Run the following Transact-SQL statement on the remote SQL Server test database:
    DROP TABLE TestNull
    GO
    CREATE TABLE TestNull (c1 INT PRIMARY KEY, c2 NVARCHAR(30)  NULL)
  2. Using an application that uses SQL Server CE RDA, pull the TestNull table into the SQL Server CE database on your handheld device.
  3. Run the following Transact-SQL statements on the SQL Server CE database to insert test values:
    INSERT INTO TestNull (c1, c2) VALUES (1, ' ') 
    INSERT INTO TestNull (c1, c2) VALUES (2, '  ')
    INSERT INTO TestNull (c1, c2) VALUES (3, '')
    INSERT INTO TestNull (c1, c2) VALUES (4, NULL)
  4. Using SQL Server CE RDA, push the TestNull table back to the remote SQL Server database.

    Note You may notice that all the rows in the TestNull table are inserted with NULL values for the c2 column on the remote SQL Server database.

REFERENCES

For more information about the Push method in SQL Server CE RDA, visit the following Microsoft Web site:

http://msdn.microsoft.com/en-us/library/aa257447(SQL.80).aspx (http://msdn.microsoft.com/en-us/library/aa257447(SQL.80).aspx)

APPLIES TO
  • Microsoft SQL Server 2000 Windows CE Edition 2.0
  • Microsoft SQL Server 2005 Compact Edition
Keywords: 
kbmobility kbclient kbtsql kbtable kbserver kbdatabase kbprb KB330741
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Nick Barton - nick NOSPAM-AT-NOSPAM websavant.co.uk Report As Irrelevant  
Written: 7/9/2006 10:42 AM
Hugely helpful - spent my whole Sunday afternoon looking for this bug. My problem was that pulling the table had rows with a char column of not null which was empty (default ''). I assumed that pushing it back with some updated columns would not be a problem as it pulled it in the first place!! Setting the column to Null sorted it out. By the way, despite what it says above - this is a problem on MSSQL 2000 (on XP) and WinCE 1.1 Thanks Nick Barton