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)
 Using prgrammatic BCP to generated a fixed format ASCII with delimiters

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-12-04 : 08:21:24
thierry writes "Hello,

Is there any chance that you have a clear example of how to export a SQL table into an ASCII table with fixed length and
a delimiter like a ';'

I almost managed to achieve what I expected but it's still
not 100 pct ASCII and not fixed. After several hours of trial
I decided to forward that to smarter persons.

Thank you for your possible help.

This is the best I could produce ..

Declare @db varchar(20), -- Database Name
@srv varchar(10), -- Server Name
@path varchar(10), -- Import Directory
@tbl varchar(255),
@cmd Varchar(1000)

Select @db = 'Dbname'
Select @srv = 'Servername'
Select @path = 'C:\BCP\' -- Import Directory
Select @tbl = 'Filename'



select @cmd = 'bcp '+ @db+ '..' + @tbl + ' out ' + @path + @db +'_'+ @tbl +'.dat' +
' -c -q /e ' + @path + @db +'_'+ @tbl +'.err' + ' /n /E ' +
' -U sa -P sa /S ' + @srv "

X002548
Not Just a Number

15586 Posts

Posted - 2003-12-04 : 14:24:28
Fixed width and delimited?

For fixed width you'll need a format file...

To Artifically delimite it make it part of a sql statement...

but why do you want to do that?



Brett

8-)
Go to Top of Page
   

- Advertisement -