[freetds] IDENTITY column problem with bcp

Lowden, James K LowdenJK at bernstein.com
Wed Apr 23 12:56:46 EDT 2003


> From: Thompson, Bill D (London) [mailto:ThompBil at exchange.uk.ml.com]
> Sent: April 23, 2003 10:50 AM
>
> >From this, I suspect what happens is if there is an identity 
> column in the
> table (we can know this from the initial describing select we 
> do from the
> table in bcp_init()), then the bcp program uses the functions 
> IDENT_SEED and
> IDENT_INCR to work out values and manually assigns the values into the
> "rows" it sends to the server.

Huh.  You must be right, because there's no option in db-lib bcp API
affecting Identity columns.  Nor even  mention, afaict.  I had read that
"... Server generates ..." description before and assumed it was something
in the protocol.  

Sybase's db-lib also doesn't mention Identity columns.  ct-lib does; an
application can send zeros to the server, and it will generate appropriate
values.  Cf. blk_props() and BLK_IDENTITY.  

With Sybase, if the server is to accept identity values, the client must
first tell the serrver to set identity_insert on.  Otherwise, the client is
expected to send zeros and let the server do the work.  That might work with
Microsoft, too; we'd obviously have to experiment.  

BTW, when Microsoft's bcp prepares to load data, it discovers the table
format by sending a query like this:

	SET FORMAT ONLY ON 
	select * from <dbname>..<tablename>
	SET FORMAT ONLY OFF

all as one string, no newlines, just spaces.  Because Sybase has no such
option, I doubt we'd ever want to change freebcp's query formulation, but it
seemed worth noting.  

Regards, 

--jkl


The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above.  If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the
original message. Please note that we do not accept account orders and/or
instructions by e-mail, and therefore will not be responsible for carrying
out such orders and/or instructions.




More information about the FreeTDS mailing list