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
 SQL Server Development (2000)
 BCP IN HELP

Author  Topic 

ELLIEMAY
Starting Member

43 Posts

Posted - 2005-02-23 : 12:03:44
I need help with importing with BCP a .csv file into my SQL table.

Example:
EXEC master.dbo.xp_cmdshell 'bcp "FTSM_CR_PATIENTS.dbo.HBOC_LIST" in @MyFile + filename -c -Sftsm-Sql1'-- -T -r\r\n'

My CSV file is NOT Static. The name changes.

Thanks in advance!

dsdeming

479 Posts

Posted - 2005-02-23 : 12:20:36
Try building the whole bcp command in a variable. Something like this:

DECLARE @a varchar( 1000 )
SET @a = 'bcp "FTSM_CR_PATIENTS.dbo.HBOC_LIST" in ' + @MyFile + ' -c -Sftsm-Sql1'
EXEC master.dbo.xp_cmdshell @a

Dennis
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-02-23 : 13:40:53
where are you executing the bcp from?

a sproc would be a good choice



Brett

8-)
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-02-24 : 01:55:38
see
http://www.mindsdoor.net/SQLTsql/ImportTextFiles.html

It monitors a folder and imports all files (that fulfill a filemask) that arrive then archives them.

==========================================
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

ELLIEMAY
Starting Member

43 Posts

Posted - 2005-03-01 : 11:07:27
Thanks. And...Yes it is in a stored proc. :)
Go to Top of Page
   

- Advertisement -