Hello,
I've a problem with SQL Server and OLE DB. SQL Server handles NULL as
NULL whereas empty string is stored as a space. This is correct when
using OLE DB but with ODBC an empty string gets converted to NULL with
SQL Server.
When migrating from ODBC to OLE DB we get errors when inserting an
empty string into foreign key columns. Therefore I guess that ODBC
drivers implicitly convert empty string to NULL. Does anyone know if
there is any parameter to set this behaviour for OLE DB connections?
Example:
CREATE TABLE foo (id VARCHAR(25) PRIMARY KEY, data VARCHAR(10))
CREATE TABLE bar (id VARCHAR(25) PRIMARY KEY, foo_id VARCHAR(25)
CONSTRAINT foo_id FOREIGN KEY(foo_id) REFERENCES foo(id) ON DELETE
CASCADE)
INSERT INTO foo VALUES ('1', 'data')
INSERT INTO bar VALUES ('1', '1')
INSERT INTO bar VALUES ('2', null)
-- possible with ODBC connect, error with OLE DB (b/c no conversion)
INSERT INTO bar VALUES ('3', '')
I'm working with legacy code under Gupta/Unify Team Developer and need
to migrate from ODBC to OLE DB, without changing all INSERTs from
empty string to NULL.
Regards
Sebastian Peters
I've a problem with SQL Server and OLE DB. SQL Server handles NULL as
NULL whereas empty string is stored as a space. This is correct when
using OLE DB but with ODBC an empty string gets converted to NULL with
SQL Server.
When migrating from ODBC to OLE DB we get errors when inserting an
empty string into foreign key columns. Therefore I guess that ODBC
drivers implicitly convert empty string to NULL. Does anyone know if
there is any parameter to set this behaviour for OLE DB connections?
Example:
CREATE TABLE foo (id VARCHAR(25) PRIMARY KEY, data VARCHAR(10))
CREATE TABLE bar (id VARCHAR(25) PRIMARY KEY, foo_id VARCHAR(25)
CONSTRAINT foo_id FOREIGN KEY(foo_id) REFERENCES foo(id) ON DELETE
CASCADE)
INSERT INTO foo VALUES ('1', 'data')
INSERT INTO bar VALUES ('1', '1')
INSERT INTO bar VALUES ('2', null)
-- possible with ODBC connect, error with OLE DB (b/c no conversion)
INSERT INTO bar VALUES ('3', '')
I'm working with legacy code under Gupta/Unify Team Developer and need
to migrate from ODBC to OLE DB, without changing all INSERTs from
empty string to NULL.
Regards
Sebastian Peters
Comment