hi,

i use this solution for an import file but give me an error. why?

"Server: Msg 208, Level 16, State 1, Procedure SP_IMPORTARARCHIVOS_BCP, Line 31
Invalid object name 'logtable'."

that is the solution

Create procedure

set quoted_identifier off
go
Create procedure usp_ImportMultipleFilesBCP @servername varchar(128),
@DatabaseName varchar(128), @filepath varchar(500), @pattern varchar(100),
@TableName varchar(128)
as
declare @query varchar(1000)
declare @max1 int
declare @count1 int
Declare @filename varchar(100)
set @count1 =0
create table #x (name varchar(200))
set @query ='master.dbo.xp_cmdshell "dir '+@filepath+@pattern +' /b"'
insert #x exec (@query)
delete from #x where name is NULL
select identity(int,1,1) as ID, name into #y from #x
drop table #x
set @max1 = (select max(ID) from #y)
--print @max1
--print @count1
--select * from #y
While @count1 <= @max1
begin
set @count1=@count1+1
set @filename = (select name from #y where [id] = @count1)
set @Query ='bcp "'+ @databasename+'.dbo.'+@Tablename + '"
in "'+ @Filepath+@Filename+'" -S' + @servername + ' -T -c -r\n -t,'
set @Query = 'MASTER.DBO.xp_cmdshell '+ "'"+ @query +"'"
--print @query
EXEC ( @query)
insert into logtable (query) select @query ?????
end

thanks!!!!
Christian from Argentina..Sud America!!!
drop table #y

Execute the Procedure

Execute the above procedure by passing the parameters shown below.

Example 1: To import all .csv files from folder c:\myimport to a table Account

Exec usp_ImportMultipleFilesBCP 'SQL','Bank','c:\Myimport\','*.csv','Account'
Example 2: To import all files from the folder c:\myimport to a table Account

Exec usp_ImportMultipleFilesBCP 'SQL','Bank','c:\Myimport\','*.*','Accoun