Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 BCP issue

Author  Topic 

SilentCodingOne
Starting Member

20 Posts

Posted - 2008-12-20 : 01:28:45
I'm working on a homework problem that requires the creation of a new table in the Northwind database. Once the table is built I have to use the bcp utility to import a tab delimited file. However whenever I try to run the commands I get the following error message:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.

Here is my bcp command:


bcp Northwind.dbo.NewEmployees in C:\NewEmployees.txt -S localhost\BILL-PC -T -c


Below is the create table script:


CREATE TABLE [dbo].[NewEmployees](
[EmployeeID] [int] NOT NULL CONSTRAINT [PK_NewEmployees] PRIMARY KEY,
[LastName] [nvarchar](20) NOT NULL,
[FirstName] [nvarchar](10) NOT NULL,
[Title] [nvarchar](30) NULL,
[TitleOfCourtesy] [nvarchar](25) NULL,
[BirthDate] [datetime] NULL,
[HireDate] [datetime] NULL,
[Address] [nvarchar](60) NULL,
[City] [nvarchar](15) NULL,
[Region] [nvarchar](15) NULL,
[PostalCode] [nvarchar](10) NULL,
[Country] [nvarchar](15) NULL,
[HomePhone] [nvarchar](24) NULL,
[Extension] [nvarchar](4) NULL,
[Notes] [ntext] NULL,
[ReportsTo] [int] NULL,
[PhotoPath] [nvarchar](255) NULL
)




I'm having a hard time figuring out the problem and would appreciate any help you guys can provide.

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-12-20 : 01:51:15
BCP is not a SQL command.

It is an operating system command, so it must be run from a command window.





CODO ERGO SUM
Go to Top of Page

SilentCodingOne
Starting Member

20 Posts

Posted - 2008-12-20 : 17:05:21
quote:
Originally posted by Michael Valentine Jones

BCP is not a SQL command.

It is an operating system command, so it must be run from a command window.




It wasn't working in the command prompt either. However I finally got it working by removing the words localhost from the server name.

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-20 : 20:19:42
localhost is a web site term and doesn't work with SQL Server unless you setup an alias named localhost. For SQL Server you can use (local), but just use the hostname instead. The hostname can be found by typing in hostname in a cmd window.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -