SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 BCP file.
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

mrjack
Yak Posting Veteran

50 Posts

Posted - 07/04/2006 :  10:42:12  Show Profile
Hi all, im new with this SQL server and found out this new feature.

I generated DAT file in my laptop, and i wanted to load it into a table in my server. hw do i proceed with it? i googled, confuse between bulk insert and openrowset...can neone enlighten me? :D



thanks
Jack

Edited by - mrjack on 07/04/2006 10:45:31

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 07/04/2006 :  11:44:11  Show Profile  Visit nr's Homepage
If you bcp'd the data out then you should bulk insert (or bcp) the data in.

You should be able to use the same bcp command just change the out to in and the table/server names.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

mrjack
Yak Posting Veteran

50 Posts

Posted - 07/04/2006 :  11:55:17  Show Profile
well...i use somekind of software to generate the BCP file..so when i want to import it in..it doesnt have the feature..heheheh..i assumed i need to do it myself..so im looking for command to get it in..

and its quite big...the DAT file is 1Gb size..
Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 07/04/2006 :  12:36:39  Show Profile  Visit nr's Homepage
You need to know the format of the file to bcp it in.
On the server try
create table #a(s varchar(8000))
bulk insert #a from 'c:\myfile.dat'
with (fieldterminator = '^', lastrow=10)
select * from #a

If it gives an error it probably means that the rows aren't crlf terminated.
In which case you will have to find the terminator.maybe

declare @sql varchar(8000)
select @sql = 'bulk insert #a from ''c:\myfile.dat''
with (fieldterminator = ''^'', rowterminator=''' + char(10) + ''' lastrow=10)'
exec (@sql)

If that doesn't work try using dts to look at it otherwise your favourite hex editor.

Are you sure it's not a propriatory format which you can't import?


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.

Edited by - nr on 07/04/2006 12:37:41
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000