Thursday, March 22, 2012
bulk insert syntax error
I try to bulk insert a table like this:
bulk insert mytable
from 'c:\mysrcfile.csv'
with
(
formatfile = 'c:\temp\bcp5.fmt',
firstrow = 2
)
and I always get :
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'from'.
I try the same thing using an exec statement, and I get the same
error..(sometimes it cannot find the format file despite it is in the
good folder...weird error)
any idea '
thanks a lot !
++
Vince--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
Should be:
bulk insert 'mytable'
from 'c:\mysrcfile.csv'
... etc. ...
Single quotes around the table name.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/ AwUBQlJQBIechKqOuFEgEQJW1gCgmsfxjrm4vipn
kluJyp0NTmbnHNgAoM9E
70q8ntQYjYA2qSoAvdZhWznS
=/TAl
--END PGP SIGNATURE--
Vince <vincent@. wrote:
> Hi there !!
> I try to bulk insert a table like this:
> bulk insert mytable
> from 'c:\mysrcfile.csv'
> with
> (
> formatfile = 'c:\temp\bcp5.fmt',
> firstrow = 2
> )
> and I always get :
> Server: Msg 156, Level 15, State 1, Line 1
> Incorrect syntax near the keyword 'from'.
> I try the same thing using an exec statement, and I get the same
> error..(sometimes it cannot find the format file despite it is in the
> good folder...weird error)|||Vince
Try
bulk insert databasename.dbo.mytable
from 'c:\mysrcfile.csv'
with
(
formatfile = 'c:\temp\bcp5.fmt',
firstrow = 2
)
"Vince .>" <vincent@.<remove> wrote in message
news:dnj45191do4jhegs41i5po0tnb0bq8v55k@.
4ax.com...
> Hi there !!
> I try to bulk insert a table like this:
> bulk insert mytable
> from 'c:\mysrcfile.csv'
> with
> (
> formatfile = 'c:\temp\bcp5.fmt',
> firstrow = 2
> )
> and I always get :
> Server: Msg 156, Level 15, State 1, Line 1
> Incorrect syntax near the keyword 'from'.
> I try the same thing using an exec statement, and I get the same
> error..(sometimes it cannot find the format file despite it is in the
> good folder...weird error)
> any idea '
>
> thanks a lot !
> ++
> Vince|||thnaks a lot..
but I always get
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'from'.
I gonna restart Query Analyser...(and why not Sql Server Services..)
>Vince
>Try
>bulk insert databasename.dbo.mytable
>from 'c:\mysrcfile.csv'
>with
>(
>formatfile = 'c:\temp\bcp5.fmt',
>firstrow = 2
> )
>
BULK INSERT SYNTAX
I am setting up a new database using a shopping cart SW, when I create the DB
using there script, I get the following error
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '('.
The line syntax is as follows.
BULK INSERT testDB.dbo.[Look-Weight] FROM 'C:\Inetpub\wwwroot\test\SQL-Admin\Look-Weight.csv';
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = ','
)
GO
What is wrong?
hi,
ShaneShowers wrote:
BULK INSERT testDB.dbo.[Look-Weight] FROM 'C:\Inetpub\wwwroot\test\SQL-Admin\Look-Weight.csv';
you have the semicolon (;) in the wrong place... at the end of the first line after the file to be imported.. the semicolon indicates a statement termination so that the next statement just becomes
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = ','
)
which makes no sense.... remove it and place it at the end of the statement
BULK INSERT testDB.dbo.[Look-Weight] FROM 'C:\Inetpub\wwwroot\test\SQL-Admin\Look-Weight.csv'
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = ','
);
regards
Bulk Insert Syntax
want to link Person 1 to every Product, something like below.
Thanks.
INSERT INTO PersonProducts (PersonID,ProductID)
VALUES (1, Products.ProductID FROM Products)INSERT INTO PersonProducts (PersonID,ProductID)
SELECT 1, Products.ProductID FROM Products|||Thanks!|||Although INSERT...SELECT is the answer to your question, I want to make it
clear that this is not bulk insert. In SQL Server, bulk insert means using
the BULK INSERT Transact-SQL statement, BCP utility, or other APIs that
perform mass insert of external data. INSERT...SELECT is simply a multi-row
insert.
I mention this to avoid confusion since bulk insert is an entirely different
beast.
Hope this helps.
Dan Guzman
SQL Server MVP
"hals_left" <cc900630@.ntu.ac.uk> wrote in message
news:1144063552.967897.165740@.i40g2000cwc.googlegroups.com...
> Hi - What is the correct syntax to bulk insert into a link table. I
> want to link Person 1 to every Product, something like below.
> Thanks.
> INSERT INTO PersonProducts (PersonID,ProductID)
> VALUES (1, Products.ProductID FROM Products)
>|||Thanks for the claification|||Hi Dan,
I am using bulk insert to transfer hugh data from a .dbf file to my sql
server table. Can you guide me in this case what shoud I specify as
fieldterminator and rowterminator?
Thanks in advance.
Regards,
Shailesh
"Dan Guzman" wrote:
> Although INSERT...SELECT is the answer to your question, I want to make it
> clear that this is not bulk insert. In SQL Server, bulk insert means usin
g
> the BULK INSERT Transact-SQL statement, BCP utility, or other APIs that
> perform mass insert of external data. INSERT...SELECT is simply a multi-r
ow
> insert.
> I mention this to avoid confusion since bulk insert is an entirely differe
nt
> beast.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "hals_left" <cc900630@.ntu.ac.uk> wrote in message
> news:1144063552.967897.165740@.i40g2000cwc.googlegroups.com...
>
>|||The BULK INSERT Transact-SQL statement is intended to import 'flat' files.
You can use DTS for 'dbf' files.
Hope this helps.
Dan Guzman
SQL Server MVP
"Shailesh" <Shailesh@.discussions.microsoft.com> wrote in message
news:57FBA5F4-30E7-47F0-A20A-D36408464782@.microsoft.com...
> Hi Dan,
> I am using bulk insert to transfer hugh data from a .dbf file to my sql
> server table. Can you guide me in this case what shoud I specify as
> fieldterminator and rowterminator?
> Thanks in advance.
> Regards,
> Shailesh
> "Dan Guzman" wrote:
>sql