Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to perform BCP Opeation

Author  Topic 

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2011-03-04 : 01:42:47
Hi,
here is the 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 UNIQUE
,CLASS_DESCRIPTION varchar(30) NOT NULL UNIQUE
,CLASS_STATUS bit NOT NULL DEFAULT 'TRUE'
)
GO


now using only bcp i need to import the data from text file .

here is the 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 columns)

But, as per my requirement How can i import text file data by using bcp


could u assist me

Thanks


--Ranjit

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2011-03-04 : 06:01:20
You can use BCP with a format file.
Look up "format files" in BOL and read the non-XML format files section
Go to Top of Page

Ranjit.ileni
Posting Yak Master

183 Posts

Posted - 2011-03-04 : 06:44:12
thank you ,

I got the expected output by using bcp with format files(making some changes) using following syntax

bcp [table_name] in [data_file_name] -f [format_file_name.fmt] -S [server name]-t, -U [username] -P [password]

--Ranjit
Go to Top of Page
   

- Advertisement -