March 3, 2011 at 11:49 pm
Hi,
here is my table
DROP TABLE dbo.ATP_MD_CLASSES
GO
CREATE TABLE dbo.ATP_MD_CLASSES
(
CLASS_ID integer NOT NULL IDENTITY(1,1)
,CLASS_SERVICE_TYPE varchar(50) NOT NULL CONSTRAINT UQ_AMCLASSES_CLASS_SERVICE_TYPE UNIQUE (CLASS_SERVICE_TYPE)
,CLASS_DESCRIPTION varchar(30) NOT NULL CONSTRAINT UQ_AMCLASSES_CLASS_DESCRIPTION UNIQUE (CLASS_DESCRIPTION)
,CLASS_STATUS bit NOT NULL DEFAULT 'TRUE'
)
GO
-- adding primary key constraint to CLASS_ID column of ATP_MD_CLASSES table
ALTER TABLE dbo.ATP_MD_CLASSES
ADD CONSTRAINT PK_AMCLASSES_CLASS_ID PRIMARY KEY (CLASS_ID)
GO
now using only bcp i need to import the data from text file .
here is my text file data(for sample)
flight1,economy,1
flifgt2,businness,0
I imported data from text file to table by using bulkinsert with formatflie(by making some changes in format file) as well as by creating a view (second , third, fouth clumns)
How can i import text file data by using bcp
could u assist me
Thanks
Ranjit
March 8, 2011 at 10:48 am
Using a view containing the second, third and fourth columns:
CREATE VIEW dbo.MY_ATP_MD_CLASSES
AS
SELECT CLASS_SERVICE_TYPE,
CLASS_DESCRIPTION,
CLASS_STATUS
FROM dbo.ATP_MD_CLASSES
This bcp command should work for you:
bcp test.dbo.MY_ATP_MD_CLASSES IN c:\a.txt -T -S .\SQLEXPRESS_2008 -c -t ,
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply