240 pts.
 How to write Bcp command to insert data in to a table
Hi, I have a file which contains the data 2:23:3#1:2:4#2:3:5 i have to insert the data in to the table in multiple rows from a single file as #--indicates to be inserted in next row : --indicates next column column1 column2 column3 2 23 3 1 2 4 2 3 5 I need to use BCP. Can any one let me know how to write the BCP command for this in t-sql Thanks

Software/Hardware used:
ASKED: December 23, 2008  2:34 PM
UPDATED: January 8, 2009  12:29 PM

Answer Wiki:
declare @bcp as varchar(200) set @bcp = 'bcp DBname.dbo.tablename in \serverfilepathtmpTestFile.txt -c -t : -r # -Sserver -Ulogin -Ppassword exec master..xp_cmdshell @bcp bcp needs full path to table and doesn't like ##temptables switches Field terminator -t Row terminator -r
Last Wiki Answer Submitted:  December 29, 2008  3:05 pm  by  Smf   170 pts.
All Answer Wiki Contributors:  Smf   170 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Thanks for your inputs..

 240 pts.