Showing posts with label isbulk. Show all posts
Showing posts with label isbulk. Show all posts

Tuesday, March 20, 2012

Bulk Insert Problem

Hi to All!
I am trying to use the 'Bulk Insert' command to load a data file into a
MS-SQL db. The line I am using is:
BULK INSERT Data..tbl_load
FROM 'C:\Data\data.txt'
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
)
Sql Server is giving error:
Server: Msg 4861, Level 16, State 1, Line 1
Could not bulk insert because file 'C:\Data\data.txt'
could not be opened. Operating system error code 3(error not found).
What is the problem in script
*** Sent via Developersdex http://www.examnotes.net ***Hi
Can you show us the text's file structure and data?
"Ghulam Farid" <gfaryd@.yahoo.com> wrote in message
news:Or$4xS$HGHA.3460@.TK2MSFTNGP12.phx.gbl...
> Hi to All!
> I am trying to use the 'Bulk Insert' command to load a data file into a
> MS-SQL db. The line I am using is:
> BULK INSERT Data..tbl_load
> FROM 'C:\Data\data.txt'
> WITH (
> DATAFILETYPE = 'char',
> FIELDTERMINATOR = '\t',
> ROWTERMINATOR = '\n'
> )
>
> Sql Server is giving error:
> Server: Msg 4861, Level 16, State 1, Line 1
> Could not bulk insert because file 'C:\Data\data.txt'
> could not be opened. Operating system error code 3(error not found).
> What is the problem in script
>
> *** Sent via Developersdex http://www.examnotes.net ***|||There is only one column in the text file and data type is "char"
sample data is like
ASU0028010180
ASU0038010181
ASU0028010182
ASU0028010183
ASU0028010184
*** Sent via Developersdex http://www.examnotes.net ***|||two things that I can think of:
Does the account that SQL Server runs with has read permissions on that file
?
The contents of the file is not encrypted, right?
"Ghulam Farid" wrote:

> There is only one column in the text file and data type is "char"
> sample data is like
>
> ASU0028010180
> ASU0038010181
> ASU0028010182
> ASU0028010183
> ASU0028010184
>
> *** Sent via Developersdex http://www.examnotes.net ***
>|||I tried to do some testing
create table ww
(
col1 int,
col2 varchar(50),
col3 varchar (50)
)
insert into ww values (47,'ReadyShip','(503)888-999')
insert into ww values (48,'MyShipper','(503)1212-454')
insert into ww values (49,'ReadyShip','(45)888-999')
insert into ww values (50,'MyShipper','(545)1212-454')
xp_cmdshell 'bcp database.dbo.ww out c:\file.fil -c -t, -SSRV -Usa -PRRR'
BULK INSERT ww FROM 'c:\file.fil' WITH (FIELDTERMINATOR = ',')
"Ghulam Farid" <gfaryd@.yahoo.com> wrote in message
news:eMePaj$HGHA.1760@.TK2MSFTNGP10.phx.gbl...
> There is only one column in the text file and data type is "char"
> sample data is like
>
> ASU0028010180
> ASU0038010181
> ASU0028010182
> ASU0028010183
> ASU0028010184
>
> *** Sent via Developersdex http://www.examnotes.net ***|||From the command-prompt, I entered:
NET HELPMSG 3
The result was:
The system cannot find the path specified.
I suggest you check to ensure 'C:\Data\data.txt' exists at the specified
location on the SQL Server. Note that the path is accessed from the server
rather than the client. Of the file resides on the client machine, you'll
need to create a share and assign file/share permissions to the SQL Server
service in order to BULK INSERT from a network location.
Hope this helps.
Dan Guzman
SQL Server MVP
"Ghulam Farid" <gfaryd@.yahoo.com> wrote in message
news:Or$4xS$HGHA.3460@.TK2MSFTNGP12.phx.gbl...
> Hi to All!
> I am trying to use the 'Bulk Insert' command to load a data file into a
> MS-SQL db. The line I am using is:
> BULK INSERT Data..tbl_load
> FROM 'C:\Data\data.txt'
> WITH (
> DATAFILETYPE = 'char',
> FIELDTERMINATOR = '\t',
> ROWTERMINATOR = '\n'
> )
>
> Sql Server is giving error:
> Server: Msg 4861, Level 16, State 1, Line 1
> Could not bulk insert because file 'C:\Data\data.txt'
> could not be opened. Operating system error code 3(error not found).
> What is the problem in script
>
> *** Sent via Developersdex http://www.examnotes.net ***|||Consider that the BULK INSERT.. command processes on the database server, so
the file data.txt would need to exist on the server HD. However, the bulk
copy DOD command (BCP.EXE) processes on the machine that it is executed on.
BCP.EXE is what you would need to use when bulk copying from a local
workstation to SQL Server.
"Ghulam Farid" <gfaryd@.yahoo.com> wrote in message
news:Or$4xS$HGHA.3460@.TK2MSFTNGP12.phx.gbl...
> Hi to All!
> I am trying to use the 'Bulk Insert' command to load a data file into a
> MS-SQL db. The line I am using is:
> BULK INSERT Data..tbl_load
> FROM 'C:\Data\data.txt'
> WITH (
> DATAFILETYPE = 'char',
> FIELDTERMINATOR = '\t',
> ROWTERMINATOR = '\n'
> )
>
> Sql Server is giving error:
> Server: Msg 4861, Level 16, State 1, Line 1
> Could not bulk insert because file 'C:\Data\data.txt'
> could not be opened. Operating system error code 3(error not found).
> What is the problem in script
>
> *** Sent via Developersdex http://www.examnotes.net ***|||Or run the BCP.exe command from the client machine.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:OhbSbGCIGHA.3944@.tk2msftngp13.phx.gbl...
> From the command-prompt, I entered:
> NET HELPMSG 3
> The result was:
> The system cannot find the path specified.
> I suggest you check to ensure 'C:\Data\data.txt' exists at the specified
> location on the SQL Server. Note that the path is accessed from the
> server rather than the client. Of the file resides on the client machine,
> you'll need to create a share and assign file/share permissions to the SQL
> Server service in order to BULK INSERT from a network location.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Ghulam Farid" <gfaryd@.yahoo.com> wrote in message
> news:Or$4xS$HGHA.3460@.TK2MSFTNGP12.phx.gbl...
>

Wednesday, March 7, 2012

Bulk Insert Command

I am trying to use the 'Bulk Insert' command to load a data file into a
MS-SQL db. The line I am using is:

Bulk Insert SVC_Details From "C:\XFILE.TXT" With (FieldTerminator = ',')

I have tried the file name with " around it and with ' around it and both
the " and ', but every time the Query Analyzer comes back with the following
error:

--Begin Error Msg--
Server: Msg 4861, Level 16, State 1, Line 1
Could not bulk insert because file ''C:\XFILE.TXT'' could not be opened.
Operating system error code 123(The filename, directory name, or volume
label syntax is incorrect.).
--End Msg--

I am not sure what is wrong with this line. Can any one tell me what is
wrong?

Mike
m charney at dunlap hospital dot orgDo not use " but use ' and be sure that the file is there

i have uset this query

bulk insert tlf.dbo.bruger_data from 'C:\TEKST.txt'
with
(
FIRSTROW = 1,
FIELDTERMINATOR = '";"',
ROWTERMINATOR = '"\n'
)

"Mike" <noway@.forgetit.com> skrev i en meddelelse
news:66x3f.181$aV5.91@.newssvr30.news.prodigy.com.. .
>I am trying to use the 'Bulk Insert' command to load a data file into a
>MS-SQL db. The line I am using is:
> Bulk Insert SVC_Details From "C:\XFILE.TXT" With (FieldTerminator = ',')
> I have tried the file name with " around it and with ' around it and both
> the " and ', but every time the Query Analyzer comes back with the
> following error:
> --Begin Error Msg--
> Server: Msg 4861, Level 16, State 1, Line 1
> Could not bulk insert because file ''C:\XFILE.TXT'' could not be opened.
> Operating system error code 123(The filename, directory name, or volume
> label syntax is incorrect.).
> --End Msg--
> I am not sure what is wrong with this line. Can any one tell me what is
> wrong?
> Mike
> m charney at dunlap hospital dot org