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 2000 Forums
 Transact-SQL (2000)
 Error Runing Bulk Insert

Author  Topic 

Sirchrisak
Starting Member

19 Posts

Posted - 2005-06-10 : 10:00:55

help me fish out the error in this code,
it is reporting an error at line 3 near ','if try to execute it with the follawing values : CSC101,Introduction to Programming,Y;CSc102 ,Manging Programming,N;. Also why insert with BULK Insert into table with Auto Id Integer dataType. Thanks
CREATE procedure dbo.STP_AddCODE
(
@CourseCode varchar(500)
)
AS
Declare @sql as varchar(200)
Set @sql='
BULK INSERT [STUDENT_COURSE_Course1]
FROM '+@CourseCode+'WITH(
FIELDTERMINATOR ='','',
ROWTERMINATOR = '';'')'
Exec(@sql)

Chris

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-10 : 10:07:59
You should give file name
See BOL for more information

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-06-11 : 10:07:14
>> Also why insert with BULK Insert into table with Auto Id Integer dataType
Easiest to use a view on the tabale which excludes the identity or you can use a format file.
As madhivanan says - bulk insert is for importing text files.
see
http://www.nigelrivett.net/SQLTsql/BCP_quoted_CSV_Format_file.html

If you have data in a variable just use string functions to insert it.
see
http://www.nigelrivett.net/SQLTsql/f_GetEntryDelimiitted.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -