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 2008 Forums
 SSIS and Import/Export (2008)
 Bulk Copy Error - Please help

Author  Topic 

Niki
Yak Posting Veteran

51 Posts

Posted - 2013-01-09 : 12:45:07
IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'TblTempCPA')
DROP TABLE TblTempCPA
GO

CREATE TABLE TblTempCPA
(

StudentNo Varchar(10) NOT NULL,
StudentName Varchar(100),
ExitReason Varchar(10),
CompletionSts Varchar(10),
CONSTRAINT pk_TblTempCPA PRIMARY KEY (StudentNo)
);

GO

bcp dbo.TblTempCPA in 'C:\Current_CPA_CTE.xlsx' -T

The error I am getting is -
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near '.'.


My excel sheet may have duplicate Studentno though. Is that the problem or BCP syntax?

Niki

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2013-01-09 : 12:57:43
BCP is a command line utility. You need to run it from a command window. If you want to run it from a query window in SSMS, you should use xp_cmdshell.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-09 : 22:43:01
see

http://www.sqlteam.com/article/exporting-data-programatically-with-bcp-and-xp_cmdshell

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -