显示标签为“thanx”的博文。显示所有博文
显示标签为“thanx”的博文。显示所有博文

2012年3月11日星期日

Bcp import - how? - question is still open

Thanx, that works! But the question is still open, how to do it using bcp
Thanx
Adam
Adam Boczek
adam.boczek@.cs-consulting.de
"Hari" <hari_prasad_k@.hotmail.com> schrieb im Newsbeitrag
news:uL0jbLHSEHA.380@.tk2msftngp13.phx.gbl...
> Hi,
> Use BULK Insert.
> 1. I have saved the contents as ccc.txt in drive.
> 2. Created a table with below script :-
> create table zz(id uniqueidentifier,name varchar(30),calories int)
> 3. Executed the below in query analyzer
> BULK INSERT master.dbo.zz
> FROM 'c:\ccc.txt'
> WITH
> (
> FIELDTERMINATOR = ','
> )
> 4. select * from zz
> id name
calories
> -- -- --
--[vbcol=seagreen]
> --
> F5F781EF-4270-4D8C-B5E0-A968F45FF771 "Ananas frisch" 60
> CA0E96D8-9017-4DDD-BF29-B78D3DC8180D "Ananas Fruchtnektar" 70
> A1777D54-9303-4AF5-A721-250A39BA731C "Ananas Fruchtsaft" 60
> DACC2063-0985-41EB-9A33-B4D8A10F1C79 "Ananas getrocknet" 300
> 04E462EC-57B1-4882-A8DF-A1EFC1B9C4F3 "Ananas kandiert" 250
> (5 row(s) affected)
> Thanks
> Hari
> MCDBA
> "Adam Boczek" <adam.boczek@.NO_SPAM.cs-consulting.de> wrote in message
> news:1086160529.62750@.proxy.ham.cs-consulting.de...
find
> a
>
This seems to work for me
C:\>bcp tempdb.dbo.zz in c:\Document.txt -t, -T -S(local) -c -F2
--
Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"Adam Boczek" <adam.boczek@.NO_SPAM.cs-consulting.de> wrote in message
news:1086163109.696219@.proxy.ham.cs-consulting.de...
> Thanx, that works! But the question is still open, how to do it using bcp
[vbcol=seagreen]
> Thanx
> Adam
> --
> ----
> Adam Boczek
> adam.boczek@.cs-consulting.de
> ----
> "Hari" <hari_prasad_k@.hotmail.com> schrieb im Newsbeitrag
> news:uL0jbLHSEHA.380@.tk2msftngp13.phx.gbl...
> calories
> -- -- --
> --
I've
> find
>
|||Wow, that's it! "-c" and also "-C" for german special signs.
Thanx,
Adam
Adam Boczek
adam.boczek@.cs-consulting.de
"Allan Mitchell" <allan@.no-spam.sqldts.com> schrieb im Newsbeitrag
news:ecRIrpHSEHA.2876@.TK2MSFTNGP09.phx.gbl...[vbcol=seagreen]
> This seems to work for me
> C:\>bcp tempdb.dbo.zz in c:\Document.txt -t, -T -S(local) -c -F2
>
> --
> --
> Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
> www.SQLDTS.com - The site for all your DTS needs.
> I support PASS - the definitive, global community
> for SQL Server professionals - http://www.sqlpass.org
>
> "Adam Boczek" <adam.boczek@.NO_SPAM.cs-consulting.de> wrote in message
> news:1086163109.696219@.proxy.ham.cs-consulting.de...
bcp[vbcol=seagreen]
>
> -- -- --
300[vbcol=seagreen]
250
> I've
>
|||ich hatte keine spezielle Deutsche Anzeichen :-)
--
Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"Adam Boczek" <adam.boczek@.NO_SPAM.cs-consulting.de> wrote in message
news:1086167420.32079@.proxy.ham.cs-consulting.de...[vbcol=seagreen]
> Wow, that's it! "-c" and also "-C" for german special signs.
> Thanx,
> Adam
> --
> ----
> Adam Boczek
> adam.boczek@.cs-consulting.de
> ----
> "Allan Mitchell" <allan@.no-spam.sqldts.com> schrieb im Newsbeitrag
> news:ecRIrpHSEHA.2876@.TK2MSFTNGP09.phx.gbl...
> bcp
> -- -- --
60[vbcol=seagreen]
70[vbcol=seagreen]
60[vbcol=seagreen]
> 300
> 250
message[vbcol=seagreen]
of[vbcol=seagreen]
I
>

2012年2月25日星期六

BCP derived fields

thanx in advance....

Pls suggest an idea to import derived fields from the data file to SQLServer2005 using the BCP utility?

eg: in the data file there are

Location UserLocId
USA 1
USA 2
IND 1
IND 2

I have to import Unique usercode like
'USA_1'
'USA_2'
'IND_1'
'IND_2'

If there is any way to upload this using BCP
( updating the usercode after loading will take more time)As you have posted a question in the articles section it is being moved to SQL Server Forum.

MODERATOR.|||

Quote:

Originally Posted by dipu vp

thanx in advance....

Pls suggest an idea to import derived fields from the data file to SQLServer2005 using the BCP utility?

eg: in the data file there are

Location UserLocId
USA 1
USA 2
IND 1
IND 2

I have to import Unique usercode like
'USA_1'
'USA_2'
'IND_1'
'IND_2'

If there is any way to upload this using BCP
( updating the usercode after loading will take more time)


i have not tried this, but here's an idea:

i think you can BCP into an existing table. so your FMT (format file) could be different from that of the existing table structure. can you try to have an format file based on Location, UserLocId structure and have an existing table with an extra calculated filed called UserCode with default value rtrim(Location) + '_' + ltrim(UserLocId )

i don't know if it will work but worth a shot.