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
 Import/Export (DTS) and Replication (2000)
 BULK INSERT

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-02-06 : 08:58:46
Annie writes "Hello

I want to import data from a text file to a database, my code looks likes the following. When I check if data is being imported, there is nothing in my database. What might be wrong with this code.

ALTER PROCEDURE serverProcess_dataImport

AS

declare @FilePath varchar(6000)
declare @File varchar(6000)
declare @sql varchar(6000)

BEGIN

SET @FilePath = 'C:\Document and Settings\Desktop'
SET @File = 'Dekany.txt'

select @sql = 'bulk insert tbl_siteSass from ''' + @FilePath + ''' , ''' + @File + ''' (fieldterminator='','')'
exec (@sql)

exec serverProcess_dataImport

END

GO

Select *
from tbl_siteSass"

nr
SQLTeam MVY

12543 Posts

Posted - 2007-02-06 : 10:58:30
try
select @sql = 'bulk insert tbl_siteSass from ''' + @FilePath + '\' + @File + ''' (fieldterminator='','')'

And I'm pretty sure you don't want the recursuive call
exec serverProcess_dataImport
==========================================
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 -