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)
 Bulk Insert variable

Author  Topic 

Sirchrisak
Starting Member

19 Posts

Posted - 2005-06-10 : 09:04:14
hi , pls help me figure out what is wrong with my code,I want to pass a Variable from where i will supply the data for my BULK INSERT operation. Each time I run it SQL willcomplain an error near @CourseCode. Thaks, here is my code


Create procedure dbo.STP_AddCODE
(
@CourseCode varchar(500)
)
AS
BULK INSERT [STUDENT_COURSE_Course1]
FROM @CourseCode
WITH
(
FIELDTERMINATOR =',',
ROWTERMINATOR = ';'

)

Chris

nellyihu
Starting Member

8 Posts

Posted - 2005-06-10 : 09:14:56
check if the name BULK INSERT is not a reserved word in T-SQL

cheers

nellysoft
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-10 : 09:18:46
[code]

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)
[/code]

Madhivanan

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

- Advertisement -