Solved

Sybase ASE BCP In With Table with No Identity Column

Posted on 2013-10-22
1
1,172 Views
Last Modified: 2013-10-23
Here's a fun one. I wanted to test some edge case stuff like tables that are not properly defined. When I have a bcp in for a table that has no IDENTITY column, I get an error. Here's the whole flow of things:

My table is defined like this:

CREATE TABLE [dbo].[XTABLE] (
            [BOGUSID] INT NOT NULL ,
            [DAT] DATETIME NOT NULL
)

No pk/identity.

I export its data (few rows ) in bcp with this:

bcp mytester.dbo.XTABLE out XTABLE.bcp -U sa -P mypass -T -n

now, I want to bring it back in using this:

bcp mytester.dbo.XTABLE in MyTable.bcp  -E -n -S Sybase_157 -U sa -P SyAdmin

The result says:

Server Message: Sybase157 - Msg 7756, Level 16, State 1:

Cannot use 'SET IDENTITY_INSERT' for table 'mytester.dbo.XTABLE' because the table does not have the identity property.

I have looked over the bcp page, but can't come up with some way to tell it it's ok to insert without identity column...

Any suggestions experts?
0
Comment
Question by:Jay Redd
1 Comment
 
LVL 24

Accepted Solution

by:
Joe Woodhouse earned 500 total points
ID: 39593387
This is correct and expected behaviour.

You used the "-E" switch, which means "the values in this BCP file are to be explicitly loaded into the identity column in this table".

You don't have an identity column in your table, hence your error message. "-E" implicitly issues the "set identity_insert on" command at the start of the bcp connection.

Try it without "-E". It should work, although note if your ASE versions are not the same you may run into issues, and if they are not running on the same platform (hardware and operating system) you may also run into (other) issues because "-n" means "native" or platform-dependent mode.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now